This commit is contained in:
2024-07-12 13:57:38 +08:00
parent 437a577cbf
commit 083c6c98dc
2 changed files with 22 additions and 3 deletions

View File

@@ -204,13 +204,23 @@ class Events extends \think\worker\Events
// 将音频数据转换为文件以便传递给iFLYTEK SDK
$tempFile = tempnam(sys_get_temp_dir(), 'audio');
file_put_contents($tempFile, $audioData);
// 设置请求参数
//$params = [
// 'sample_rate' => 16000, // 采样率
// 'language' => 'zh_cn', // 语言
//];
// 设置转写参数
$lfasrConfig = [
'hasParticiple' => 'true'
'hasParticiple' => 'true',
'sample_rate' => 16000, // 采样率
'language' => 'zh_cn', // 语言
//...
];
$app_id = 'de02da3d';
$secret_key = 'MjcyOGE5ODg3ODM2ZWU5MTNiODc0M2Zl';
$xunfei_record_config = config('xunfei_record_config');
$app_id = $xunfei_record_config['appid'];
$secret_key = $xunfei_record_config['secretKey'];
$filePath = $tempFile;//'/Users/wh/Desktop/test.wav';
// 这里的$app_id、$secret_key是在开放平台控制台获得
$client = new LfasrClient($app_id, $secret_key, $lfasrConfig);
@@ -227,6 +237,10 @@ class Events extends \think\worker\Events
// 清理临时文件
unlink($tempFile);
// 处理翻译结果,例如保存到数据库或返回给前端
Gateway::sendToClient($client_id, $result);
}

View File

@@ -196,6 +196,11 @@ return [
'base_url'=>'https://serverfastgpt.excn.top/api/v1/chat/completions',
'APIKey'=>'fastgpt-e5wq9u6phvyfq4znrXfOuTHKHQHGjpcVBYay602ai5zv4HeOJRMDwT3ptm6',
],
//讯飞录音接口
'xunfei_record_config'=>[
'secretKey'=>'MjcyOGE5ODg3ODM2ZWU5MTNiODc0M2Zl',
'appid'=>'de02da3d'
],
//业务基础架构配置
'service_framework_config'=>[
//内网访问架构中放行的端口