php调用百度语音API实例

php调用百度语音API实例

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?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();




?>
-------------本文结束 感谢您的阅读-------------
转载别忘了注明出处哈
🍭🍭🍭😜
0%