mirror of
https://github.com/open-webui/open-webui.git
synced 2026-11-17 15:53:59 -06:00
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
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user