This commit is contained in:
2024-07-12 20:05:22 +08:00
parent a6eccf5cd8
commit bf276c34b3

View File

@@ -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()生成随机数