<?php require_once 'AipSpeech.php'; // 你的 APPID AK SK // 你的 APPID AK SK const APP_ID = '19425765'; const API_KEY = 'hi4cN5q8XQnBCbBVQ3KmFxW8'; const SECRET_KEY = 'Vj9Xj8oG3GZyD7faS30wVHSNqhjppr6b'; $client = new AipSpeech(APP_ID, API_KEY, SECRET_KEY); // 识别本地文件
$li = $client->asr(file_get_contents('./test.wav'), 'wav', 16000, array( 'lan' => 'zh', )); interface Msg{ function getMsg(); } class Result implements Msg{ protected $res = null; protected function __construct($re){ $this->res = $re; } public function getMsg(){} } class Success extends Result{ public function __construct($re){ parent::__construct($re); } public function getMsg(){ if ($this->res['err_msg'] == 'success.') { // var_dump($this->res);exit; echo $this->res['result'][0]; } } } $tmp = new Success($li); $tmp->getMsg(); ?>