From bf276c34b386dc994b71c284a2e97e5fcfe06668 Mon Sep 17 00:00:00 2001 From: wh <382379437@qq.com> Date: Fri, 12 Jul 2024 20:05:22 +0800 Subject: [PATCH] fixed --- .../application/index/controller/Test.php | 32 ++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/digital_doctor/application/index/controller/Test.php b/digital_doctor/application/index/controller/Test.php index 794ed05..5cca174 100644 --- a/digital_doctor/application/index/controller/Test.php +++ b/digital_doctor/application/index/controller/Test.php @@ -12,6 +12,7 @@ namespace app\index\controller; use app\api\controller\BaseCommonController; use app\api\logic\AudioRevertLogic; use app\api\logic\UserLogic; +use IFlytek\Xfyun\Speech\LfasrClient; use think\Controller; use think\Db; use think\facade\Request; @@ -27,9 +28,38 @@ class Test extends BasePublicController { function test() { + $xunfei_record_config = config('xunfei_record_config'); + $appId = $xunfei_record_config['appid']; + $secretKey = $xunfei_record_config['secretKey']; + + // 设置转写参数 + $lfasrConfig = [ + 'hasParticiple' => 'true' + //... + ]; + + dump($xunfei_record_config); +// 这里的$app_id、$secret_key是在开放平台控制台获得 + $client = new LfasrClient($appId, $secretKey, $lfasrConfig); + + dump($client); + $filePath = Tools::get_root_path().'public/iseTest.mp3'; + dump($filePath); +// $filePath为待转写的本地文件路径,返回taskId作为后续查询进度、获取结果操作的参数 + $taskId = $client->combineUpload($filePath); + dump($taskId); + +// 查询进度,json格式 + $progress = $client->getProgress($taskId)->getBody()->getContents(); + dump($progress); + +// 获取结果,json格式 + $result = $client->getResult($taskId)->getBody()->getContents(); + dump($result); + //(new AudioRevertLogic())->revert('asdsssssssssss',''); - (new AudioRevertLogic())->revert_test('asdsssssssssss',''); + //(new AudioRevertLogic())->revert_test('asdsssssssssss',''); //revert_test // 使用mt_rand()生成随机数