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:
huozaimengli
2026-01-29 16:39:35 +08:00
parent 15650e1a6c
commit 614b662e3d
15 changed files with 44 additions and 35 deletions
@@ -24,10 +24,9 @@ class ASRProvider(ASRProviderBase):
def requires_file(self) -> bool:
return True
async def speech_to_text(self, opus_data: List[bytes], session_id: str, audio_format="opus") -> Tuple[Optional[str], Optional[str]]:
async def speech_to_text(self, opus_data: List[bytes], session_id: str, audio_format="opus", artifacts=None) -> Tuple[Optional[str], Optional[str]]:
file_path = None
try:
artifacts = self.get_current_artifacts()
if artifacts is None:
return "", None
file_path = artifacts.file_path