mirror of
https://github.com/open-webui/open-webui.git
synced 2026-10-07 02:58:21 +00: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:
parent
de9234a2b8
commit
1e834c09e2
1 changed files with 7 additions and 3 deletions
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue