From 088943166c58261166e2c1c71ba7c3ec0d8bd0ce Mon Sep 17 00:00:00 2001 From: Xin Wang Date: Mon, 9 Feb 2026 17:24:15 +0800 Subject: [PATCH] Update asr interim --- engine/core/duplex_pipeline.py | 20 ++++++++++++-------- web/pages/Assistants.tsx | 14 ++++---------- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/engine/core/duplex_pipeline.py b/engine/core/duplex_pipeline.py index 16abd68..074189a 100644 --- a/engine/core/duplex_pipeline.py +++ b/engine/core/duplex_pipeline.py @@ -414,6 +414,8 @@ class DuplexPipeline: ) }) + if not is_final: + logger.info(f"ASR interim: {text[:100]}") logger.debug(f"Sent transcript ({'final' if is_final else 'interim'}): {text[:50]}...") async def _on_speech_start(self) -> None: @@ -463,14 +465,16 @@ class DuplexPipeline: logger.info(f"EOU detected - user said: {user_text[:100]}...") - # Send final transcription to client - await self.transport.send_event({ - **ev( - "transcript.final", - trackId=self.session_id, - text=user_text, - ) - }) + # For ASR backends that already emitted final via callback, + # avoid duplicating transcript.final on EOU. + if user_text != self._last_sent_transcript: + await self.transport.send_event({ + **ev( + "transcript.final", + trackId=self.session_id, + text=user_text, + ) + }) # Clear buffers self._audio_buffer = b"" diff --git a/web/pages/Assistants.tsx b/web/pages/Assistants.tsx index 2930e7e..1af4b2f 100644 --- a/web/pages/Assistants.tsx +++ b/web/pages/Assistants.tsx @@ -1703,16 +1703,10 @@ export const DebugDrawer: React.FC<{ } const last = prev[prev.length - 1]; if (last?.role === 'user') { - if (last.text === finalText) { - lastUserFinalRef.current = finalText; - return prev; - } - if (finalText.startsWith(last.text) || last.text.startsWith(finalText)) { - const next = [...prev]; - next[next.length - 1] = { ...last, text: finalText }; - lastUserFinalRef.current = finalText; - return next; - } + const next = [...prev]; + next[next.length - 1] = { ...last, text: finalText }; + lastUserFinalRef.current = finalText; + return next; } lastUserFinalRef.current = finalText; return [...prev, { role: 'user', text: finalText }];