소스 검색

fix(asr): concatenate streaming ASR chunks instead of keeping only last

Streaming Mimo ASR returns text in fragments (e.g. '嗯' then '。').
Previous code overwrote with each chunk, keeping only final punctuation.
Now correctly concatenates all chunks.
wenhongquan 3 주 전
부모
커밋
ca38fff29c
1개의 변경된 파일2개의 추가작업 그리고 2개의 파일을 삭제
  1. 2 2
      asr_agent/conversation_worker.py

+ 2 - 2
asr_agent/conversation_worker.py

@@ -181,7 +181,7 @@ async def _asr_transcribe(audio_data: np.ndarray, asr_engine=None) -> str:
         text = ""
         async for chunk, is_done in _asr_mimo_stream(audio_data):
             if chunk:
-                text = chunk  # last partial becomes final
+                text += chunk
         return text.strip()
     loop = asyncio.get_running_loop()
     result = await loop.run_in_executor(None, asr_engine.transcribe_array, audio_data)
@@ -213,7 +213,7 @@ async def _asr_mimo_stream(audio_data: np.ndarray):
                         "data": f"data:audio/wav;base64,{audio_b64}"}}
                 ]}],
                 "stream": True,
-                "extra_body": {"asr_options": {"language": "auto"}},
+                "asr_options": {"language": "auto"},
             },
             headers=h, timeout=aiohttp.ClientTimeout(total=20),
         ) as r: