diff options
author | Heiner Lohaus <hlohaus@users.noreply.github.com> | 2024-04-13 21:41:40 +0200 |
---|---|---|
committer | Heiner Lohaus <hlohaus@users.noreply.github.com> | 2024-04-13 21:41:40 +0200 |
commit | cec2a10eaabe04b0cd7bac343e669f75150fce7c (patch) | |
tree | 7d707cbcac86ecdf22d377ad7dbdfee9a4122bd7 /g4f/gui/client/static/js | |
parent | Fix SpeechRecognition on Phone (diff) | |
download | gpt4free-cec2a10eaabe04b0cd7bac343e669f75150fce7c.tar gpt4free-cec2a10eaabe04b0cd7bac343e669f75150fce7c.tar.gz gpt4free-cec2a10eaabe04b0cd7bac343e669f75150fce7c.tar.bz2 gpt4free-cec2a10eaabe04b0cd7bac343e669f75150fce7c.tar.lz gpt4free-cec2a10eaabe04b0cd7bac343e669f75150fce7c.tar.xz gpt4free-cec2a10eaabe04b0cd7bac343e669f75150fce7c.tar.zst gpt4free-cec2a10eaabe04b0cd7bac343e669f75150fce7c.zip |
Diffstat (limited to '')
-rw-r--r-- | g4f/gui/client/static/js/chat.v1.js | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/g4f/gui/client/static/js/chat.v1.js b/g4f/gui/client/static/js/chat.v1.js index 0f3c5d65..3da43d95 100644 --- a/g4f/gui/client/static/js/chat.v1.js +++ b/g4f/gui/client/static/js/chat.v1.js @@ -1261,22 +1261,22 @@ if (SpeechRecognition) { recognition.interimResults = true; recognition.maxAlternatives = 1; - function may_stop() { - if (microLabel.classList.contains("recognition")) { - recognition.stop(); - } - } - let startValue; + let shouldStop = false; let lastDebounceTranscript; recognition.onstart = function() { microLabel.classList.add("recognition"); startValue = messageInput.value; + shouldStop = false; lastDebounceTranscript = ""; }; recognition.onend = function() { - microLabel.classList.remove("recognition"); - messageInput.focus(); + if (shouldStop) { + microLabel.classList.remove("recognition"); + messageInput.focus(); + } else { + recognition.start(); + } }; recognition.onresult = function(event) { if (!event.results) { @@ -1303,6 +1303,7 @@ if (SpeechRecognition) { microLabel.addEventListener("click", () => { if (microLabel.classList.contains("recognition")) { + shouldStop = true; recognition.stop(); } else { const lang = document.getElementById("recognition-language")?.value; |