Fix asr begin error

This commit is contained in:
Xin Wang
2026-02-12 16:52:42 +08:00
parent 543528239e
commit aabf2ce8b9

View File

@@ -813,6 +813,12 @@ class DuplexPipeline:
# Prime ASR with a short pre-speech context window so the utterance
# start isn't lost while waiting for VAD to transition to Speech.
pre_roll = self._pre_speech_buffer
# _pre_speech_buffer already includes current speech frames; avoid
# duplicating onset audio when we append pending speech below.
if self._pending_speech_audio and len(pre_roll) > len(self._pending_speech_audio):
pre_roll = pre_roll[:-len(self._pending_speech_audio)]
elif self._pending_speech_audio:
pre_roll = b""
capture_audio = pre_roll + self._pending_speech_audio
if capture_audio:
await self.asr_service.send_audio(capture_audio)