mirror of
https://github.com/xtekky/gpt4free.git
synced 2024-12-28 05:33:23 +03:00
Merge branch 'main' of https://github.com/xtekky/gpt4free
This commit is contained in:
commit
46dcf08554
@ -1074,7 +1074,7 @@ async function load_version() {
|
||||
}
|
||||
setTimeout(load_version, 2000);
|
||||
|
||||
for (const el of [imageInput, cameraInput]) {
|
||||
[imageInput, cameraInput].forEach((el) => {
|
||||
el.addEventListener('click', async () => {
|
||||
el.value = '';
|
||||
if (imageInput.dataset.src) {
|
||||
@ -1082,7 +1082,7 @@ for (const el of [imageInput, cameraInput]) {
|
||||
delete imageInput.dataset.src
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
fileInput.addEventListener('click', async (event) => {
|
||||
fileInput.value = '';
|
||||
@ -1261,31 +1261,26 @@ if (SpeechRecognition) {
|
||||
recognition.interimResults = true;
|
||||
recognition.maxAlternatives = 1;
|
||||
|
||||
function may_stop() {
|
||||
if (microLabel.classList.contains("recognition")) {
|
||||
recognition.stop();
|
||||
}
|
||||
}
|
||||
|
||||
let startValue;
|
||||
let timeoutHandle;
|
||||
let shouldStop;
|
||||
let lastDebounceTranscript;
|
||||
recognition.onstart = function() {
|
||||
microLabel.classList.add("recognition");
|
||||
startValue = messageInput.value;
|
||||
shouldStop = false;
|
||||
lastDebounceTranscript = "";
|
||||
timeoutHandle = window.setTimeout(may_stop, 10000);
|
||||
};
|
||||
recognition.onend = function() {
|
||||
microLabel.classList.remove("recognition");
|
||||
messageInput.focus();
|
||||
if (shouldStop) {
|
||||
messageInput.focus();
|
||||
} else {
|
||||
recognition.start();
|
||||
}
|
||||
};
|
||||
recognition.onresult = function(event) {
|
||||
if (!event.results) {
|
||||
return;
|
||||
}
|
||||
window.clearTimeout(timeoutHandle);
|
||||
|
||||
let result = event.results[event.resultIndex];
|
||||
let isFinal = result.isFinal && (result[0].confidence > 0);
|
||||
let transcript = result[0].transcript;
|
||||
@ -1303,14 +1298,13 @@ if (SpeechRecognition) {
|
||||
messageInput.style.height = messageInput.scrollHeight + "px";
|
||||
messageInput.scrollTop = messageInput.scrollHeight;
|
||||
}
|
||||
|
||||
timeoutHandle = window.setTimeout(may_stop, transcript ? 10000 : 8000);
|
||||
};
|
||||
|
||||
microLabel.addEventListener("click", () => {
|
||||
if (microLabel.classList.contains("recognition")) {
|
||||
window.clearTimeout(timeoutHandle);
|
||||
shouldStop = true;
|
||||
recognition.stop();
|
||||
microLabel.classList.remove("recognition");
|
||||
} else {
|
||||
const lang = document.getElementById("recognition-language")?.value;
|
||||
recognition.lang = lang || navigator.language;
|
||||
|
Loading…
Reference in New Issue
Block a user