Clear stale ASR capture on end of utterance in DuplexPipeline. Add test to verify behavior when conversation state changes, ensuring proper handling of ASR capture variables.

This commit is contained in:
Xin Wang
2026-02-28 12:32:35 +08:00
parent 8b59569b99
commit aae41d4512
2 changed files with 22 additions and 0 deletions

View File

@@ -1393,6 +1393,11 @@ class DuplexPipeline:
async def _on_end_of_utterance(self) -> None:
"""Handle end of user utterance."""
if self.conversation.state not in (ConversationState.LISTENING, ConversationState.INTERRUPTED):
# Prevent a stale ASR capture watchdog from repeatedly forcing EOU
# once the conversation has already moved past user-listening states.
self._asr_capture_active = False
self._asr_capture_started_ms = 0.0
self._pending_speech_audio = b""
return
# Add a tiny trailing silence tail to stabilize final-token decoding.