From 1e834c09e2db913330e4029ea5eb66b40aff70a7 Mon Sep 17 00:00:00 2001 From: Classic298 <27028174+Classic298@users.noreply.github.com> Date: Mon, 5 Oct 2026 04:45:11 +0200 Subject: [PATCH] fix: Web API dictation stops while you are still talking (#31891) With the Web API speech-to-text engine, the two-second silence timer only restarted when the browser finished a phrase. If you paused briefly and then kept talking for more than two seconds, dictation stopped mid-sentence. The timer now restarts whenever the browser hears speech, so dictation only stops after two seconds of silence. Fixes #19727 --- .../components/chat/MessageInput/VoiceRecording.svelte | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/lib/components/chat/MessageInput/VoiceRecording.svelte b/src/lib/components/chat/MessageInput/VoiceRecording.svelte index 88048ec1a2..783085d9b8 100644 --- a/src/lib/components/chat/MessageInput/VoiceRecording.svelte +++ b/src/lib/components/chat/MessageInput/VoiceRecording.svelte @@ -308,6 +308,8 @@ // Set continuous to true for continuous recognition speechRecognition.continuous = true; + // Interim results keep the inactivity timeout from firing mid-sentence + speechRecognition.interimResults = true; // Set the timeout for turning off the recognition after inactivity (in milliseconds) const inactivityTimeout = 2000; // 3 seconds @@ -323,9 +325,11 @@ // Handle recognized speech console.log(event); - const transcript = event.results[Object.keys(event.results).length - 1][0].transcript; - - transcription = `${transcription}${transcript}`; + for (const result of Array.from(event.results).slice(event.resultIndex)) { + if (result.isFinal) { + transcription = `${transcription}${result[0].transcript}`; + } + } await tick(); document.getElementById('chat-input')?.focus();