summaryrefslogtreecommitdiffstats
path: root/g4f
diff options
context:
space:
mode:
authorHeiner Lohaus <hlohaus@users.noreply.github.com>2024-04-13 21:35:57 +0200
committerHeiner Lohaus <hlohaus@users.noreply.github.com>2024-04-13 21:35:57 +0200
commitf323e8850aaee3be3f98205d3b87d03ea485c1c2 (patch)
tree8d76ead553709f3ebfde067a16e53959ff8c8c09 /g4f
parentFix SpeechRecognition on Phone (diff)
downloadgpt4free-f323e8850aaee3be3f98205d3b87d03ea485c1c2.tar
gpt4free-f323e8850aaee3be3f98205d3b87d03ea485c1c2.tar.gz
gpt4free-f323e8850aaee3be3f98205d3b87d03ea485c1c2.tar.bz2
gpt4free-f323e8850aaee3be3f98205d3b87d03ea485c1c2.tar.lz
gpt4free-f323e8850aaee3be3f98205d3b87d03ea485c1c2.tar.xz
gpt4free-f323e8850aaee3be3f98205d3b87d03ea485c1c2.tar.zst
gpt4free-f323e8850aaee3be3f98205d3b87d03ea485c1c2.zip
Diffstat (limited to 'g4f')
-rw-r--r--g4f/gui/client/static/js/chat.v1.js18
1 files changed, 2 insertions, 16 deletions
diff --git a/g4f/gui/client/static/js/chat.v1.js b/g4f/gui/client/static/js/chat.v1.js
index 4ba0cd93..0f3c5d65 100644
--- a/g4f/gui/client/static/js/chat.v1.js
+++ b/g4f/gui/client/static/js/chat.v1.js
@@ -1261,38 +1261,27 @@ if (SpeechRecognition) {
recognition.interimResults = true;
recognition.maxAlternatives = 1;
- let shouldStop = false;
function may_stop() {
if (microLabel.classList.contains("recognition")) {
- shouldStop = true
recognition.stop();
}
}
let startValue;
- let timeoutHandle;
let lastDebounceTranscript;
recognition.onstart = function() {
microLabel.classList.add("recognition");
startValue = messageInput.value;
lastDebounceTranscript = "";
- timeoutHandle = window.setTimeout(may_stop, 10000);
};
recognition.onend = function() {
- if (shouldStop) {
- microLabel.classList.remove("recognition");
- messageInput.focus();
- } else {
- recognition.start();
- }
+ microLabel.classList.remove("recognition");
+ messageInput.focus();
};
recognition.onresult = function(event) {
- window.clearTimeout(timeoutHandle);
- timeoutHandle = window.setTimeout(may_stop, 8000);
if (!event.results) {
return;
}
-
let result = event.results[event.resultIndex];
let isFinal = result.isFinal && (result[0].confidence > 0);
let transcript = result[0].transcript;
@@ -1314,13 +1303,10 @@ if (SpeechRecognition) {
microLabel.addEventListener("click", () => {
if (microLabel.classList.contains("recognition")) {
- window.clearTimeout(timeoutHandle);
- shouldStop = true;
recognition.stop();
} else {
const lang = document.getElementById("recognition-language")?.value;
recognition.lang = lang || navigator.language;
- shouldStop = false;
recognition.start();
}
});