diff --git a/main/manager-api/src/main/resources/db/changelog/202512221117.sql b/main/manager-api/src/main/resources/db/changelog/202512221117.sql new file mode 100644 index 00000000..4a3c8d24 --- /dev/null +++ b/main/manager-api/src/main/resources/db/changelog/202512221117.sql @@ -0,0 +1,10 @@ +-- 更新豆包流式ASR供应器,增加end_window_size配置 +delete from `ai_model_provider` where id = 'SYSTEM_ASR_DoubaoStreamASR'; +INSERT INTO `ai_model_provider` (`id`, `model_type`, `provider_code`, `name`, `fields`, `sort`, `creator`, `create_date`, `updater`, `update_date`) VALUES +('SYSTEM_ASR_DoubaoStreamASR', 'ASR', 'doubao_stream', '火山引擎语音识别(流式)', '[{"key":"appid","label":"应用ID","type":"string"},{"key":"access_token","label":"访问令牌","type":"string"},{"key":"cluster","label":"集群","type":"string"},{"key":"boosting_table_name","label":"热词文件名称","type":"string"},{"key":"correct_table_name","label":"替换词文件名称","type":"string"},{"key":"output_dir","label":"输出目录","type":"string"},{"key":"end_window_size","label":"静音判定时长(ms)","type":"number"}]', 3, 1, NOW(), 1, NOW()); + + +-- 更新豆包流式ASR模型配置,增加end_window_size默认值 +UPDATE `ai_model_config` SET +`config_json` = JSON_SET(`config_json`, '$.end_window_size', 200) +WHERE `id` = 'ASR_DoubaoStreamASR' AND JSON_EXTRACT(`config_json`, '$.end_window_size') IS NULL; diff --git a/main/manager-api/src/main/resources/db/changelog/db.changelog-master.yaml b/main/manager-api/src/main/resources/db/changelog/db.changelog-master.yaml index 22d0d431..e8209c82 100755 --- a/main/manager-api/src/main/resources/db/changelog/db.changelog-master.yaml +++ b/main/manager-api/src/main/resources/db/changelog/db.changelog-master.yaml @@ -458,4 +458,11 @@ databaseChangeLog: changes: - sqlFile: encoding: utf8 - path: classpath:db/changelog/202512192245.sql \ No newline at end of file + path: classpath:db/changelog/202512192245.sql + - changeSet: + id: 202512221117 + author: RanChen + changes: + - sqlFile: + encoding: utf8 + path: classpath:db/changelog/202512221117.sql \ No newline at end of file diff --git a/main/xiaozhi-server/config.yaml b/main/xiaozhi-server/config.yaml index f2bbe9be..4f9b8f1e 100644 --- a/main/xiaozhi-server/config.yaml +++ b/main/xiaozhi-server/config.yaml @@ -346,6 +346,8 @@ ASR: # 热词、替换词使用流程:https://www.volcengine.com/docs/6561/155738 boosting_table_name: (选填)你的热词文件名称 correct_table_name: (选填)你的替换词文件名称 + # 静音判定时长(ms),默认200ms + end_window_size: 200 output_dir: tmp/ TencentASR: # token申请地址:https://console.cloud.tencent.com/cam/capi diff --git a/main/xiaozhi-server/core/providers/asr/doubao_stream.py b/main/xiaozhi-server/core/providers/asr/doubao_stream.py index 0c1cf727..9c667952 100644 --- a/main/xiaozhi-server/core/providers/asr/doubao_stream.py +++ b/main/xiaozhi-server/core/providers/asr/doubao_stream.py @@ -47,6 +47,8 @@ class ASRProvider(ASRProviderBase): self.channel = config.get("channel", 1) self.auth_method = config.get("auth_method", "token") self.secret = config.get("secret", "access_secret") + end_window_size = config.get("end_window_size") + self.end_window_size = int(end_window_size) if end_window_size else 200 async def open_audio_channels(self, conn): await super().open_audio_channels(conn) @@ -291,7 +293,7 @@ class ASRProvider(ASRProviderBase): "sequence": 1, "boosting_table_name": self.boosting_table_name, "correct_table_name": self.correct_table_name, - "end_window_size": 200, + "end_window_size": self.end_window_size, }, "audio": { "format": self.format,