mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-31 02:23:56 +08:00
refactor(asr): 重构speech_to_text方法以接收artifacts参数
移除各ASR提供者中重复的get_current_artifacts调用,改为通过参数传递artifacts 修改base类中process_audio方法,根据combined_pcm_data长度决定是否创建artifacts 更新所有speech_to_text方法签名,添加artifacts可选参数并更新文档字符串
This commit is contained in:
@@ -30,7 +30,7 @@ class ASRProvider(ASRProviderBase):
|
||||
os.makedirs(self.output_dir, exist_ok=True)
|
||||
|
||||
async def speech_to_text(
|
||||
self, opus_data: List[bytes], session_id: str, audio_format="opus"
|
||||
self, opus_data: List[bytes], session_id: str, audio_format="opus", artifacts=None
|
||||
) -> Tuple[Optional[str], Optional[str]]:
|
||||
"""将语音数据转换为文本"""
|
||||
if not opus_data:
|
||||
@@ -43,7 +43,6 @@ class ASRProvider(ASRProviderBase):
|
||||
logger.bind(tag=TAG).error("百度语音识别配置未设置,无法进行识别")
|
||||
return None, None
|
||||
|
||||
artifacts = self.get_current_artifacts()
|
||||
if artifacts is None:
|
||||
return "", None
|
||||
|
||||
|
||||
Reference in New Issue
Block a user