Enhance DuplexPipeline and AssistantsPage for improved interruption handling. Introduce _OPENER_PRE_ROLL_MS constant for a head start on mic capture, and adjust interruption sensitivity settings from 500ms to 180ms across relevant components to optimize responsiveness during assistant interactions.

This commit is contained in:
Xin Wang
2026-02-27 11:51:15 +08:00
parent 6a9b5fcff4
commit 71cbfa2b48
2 changed files with 16 additions and 11 deletions

View File

@@ -73,6 +73,7 @@ class DuplexPipeline:
_ASR_DELTA_THROTTLE_MS = 500
_LLM_DELTA_THROTTLE_MS = 80
_ASR_CAPTURE_MAX_MS = 15000
_OPENER_PRE_ROLL_MS = 180
_DEFAULT_TOOL_SCHEMAS: Dict[str, Dict[str, Any]] = {
"current_time": {
"name": "current_time",
@@ -781,6 +782,9 @@ class DuplexPipeline:
)
await self.conversation.add_assistant_turn(greeting_to_speak)
# Give client mic capture a short head start so opener can be interrupted immediately.
await asyncio.sleep(self._OPENER_PRE_ROLL_MS / 1000.0)
used_preloaded_audio = await self._play_preloaded_opener_audio()
if self._tts_output_enabled() and not used_preloaded_audio:
# Keep opener text ahead of opener voice start.