summaryrefslogtreecommitdiffstats
path: root/g4f
diff options
context:
space:
mode:
Diffstat (limited to 'g4f')
-rw-r--r--g4f/gui/client/static/js/chat.v1.js17
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;