ソースを参照

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: