更新iat流式语音

This commit is contained in:
yaooo 2023-10-09 20:08:32 +08:00
parent 7b11793d7e
commit 21a9cb77e8

View File

@ -127,7 +127,7 @@ class XunFeiController extends BaseApiController
$hostUrl = "ws://iat-api.xfyun.cn/v2/iat";
// 请填写您的音频文件路径
$file = storage_path() . '/app/public/audio/1675996119143.mp3';
// $file = storage_path() . '/app/public/audio/1675996119143.mp3';
$st = microtime(true);
@ -136,10 +136,10 @@ class XunFeiController extends BaseApiController
$client = new Client($authUrl);
//打开音频文件
$audioFile = fopen($file, 'rb');
if ($audioFile === false) {
throw new \Exception('open file error');
}
// $audioFile = fopen($file, 'rb');
// if ($audioFile === false) {
// throw new \Exception('open file error');
// }
$frameSize = 1280; //每一帧的音频大小
$intervel = 40 * 1000; //发送音频间隔
@ -244,12 +244,7 @@ class XunFeiController extends BaseApiController
echo "无法连接到 WebSocket 服务器";
}
fclose($audioFile);
// fclose($audioFile);
usleep(1); //等待数据接收完成
}