From 10cf077848b0007e1b0e19b0bf3d370d35c858b8 Mon Sep 17 00:00:00 2001 From: Concedo <39025047+LostRuins@users.noreply.github.com> Date: Sat, 1 Jun 2024 10:56:00 +0800 Subject: [PATCH] tweaking audio capture --- klite.embd | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/klite.embd b/klite.embd index a5de46e7f..4a7280406 100644 --- a/klite.embd +++ b/klite.embd @@ -9250,6 +9250,7 @@ Current version: 142 selected_workers = []; localsettings.opmode = 1; } + hide_popups(); restart_new_game(true, document.getElementById("keep_memory").checked); hide_popups(); } @@ -10089,10 +10090,14 @@ Current version: 142 playSound.buffer = decodedData; playSound.connect(audioContext.destination); xtts_is_playing = true; + update_submit_button(false); playSound.start(audioContext.currentTime); playSound.onended = function() { - xtts_is_playing = false; - console.log("Audio finished playing"); + setTimeout(() => { + xtts_is_playing = false; + update_submit_button(false); + console.log("Audio finished playing"); + },300); }; }).catch((error) => { console.log("XTTS Speak Error: " + error); @@ -10128,10 +10133,14 @@ Current version: 142 playSound.buffer = decodedData; playSound.connect(audioContext.destination); xtts_is_playing = true; + update_submit_button(false); playSound.start(audioContext.currentTime); playSound.onended = function() { - xtts_is_playing = false; - console.log("Audio finished playing"); + setTimeout(() => { + xtts_is_playing = false; + update_submit_button(false); + console.log("Audio finished playing"); + },300); }; }).catch((error) => { console.log("AllTalk Speak Error: " + error); @@ -10145,6 +10154,9 @@ Current version: 142 let utterance = new window.SpeechSynthesisUtterance(text); utterance.voice = window.speechSynthesis.getVoices()[ssval - 1]; window.speechSynthesis.speak(utterance); + utterance.onend = function(event) { + update_submit_button(false); + }; } } } @@ -12664,7 +12676,7 @@ Current version: 142 voice_is_recording = false; update_submit_button(false); } - }, "500"); //prevent premature stopping + }, 500); //prevent premature stopping }, voice_start: function () { is_speaking = true;