From 773ccaafd5752a9b2c800f055f7af682ee5ef9ea Mon Sep 17 00:00:00 2001 From: ebolam Date: Tue, 6 Dec 2022 12:40:48 -0500 Subject: [PATCH] TTS now continues speaking the next chunk if one exists. --- static/koboldai.js | 34 ++++++++++++++++++++++------------ templates/settings flyout.html | 2 +- 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/static/koboldai.js b/static/koboldai.js index d2225646..49bf3a00 100644 --- a/static/koboldai.js +++ b/static/koboldai.js @@ -3167,20 +3167,17 @@ function retry_from_here() { } } -function speak_audio() { - let chunk = null; - for (element of document.getElementsByClassName("editing")) { - if (element.id == 'story_prompt') { - chunk = -1 - } else { - chunk = parseInt(element.id.split(" ").at(-1)); - } - element.classList.remove("editing"); +function speak_audio(summonEvent) { + let action_id = null; + if (summonEvent.target.parentElement.id == "story_prompt") { + action_id = -1; + } else { + action_id = summonEvent.target.parentElement.id.split(" ").at(-1); } - if (chunk != null) { - action_count = parseInt(document.getElementById("action_count").textContent); + if (action_id != null) { //console.log(chunk); - document.getElementById("reader").src = "/audio?id="+chunk; + document.getElementById("reader").src = "/audio?id="+action_id; + document.getElementById("reader").setAttribute("action_id", action_id); document.getElementById("reader").play(); document.getElementById("play_tts").textContent = "pause"; } @@ -3202,6 +3199,19 @@ function stop_tts() { document.getElementById("play_tts").textContent = "play_arrow"; } +function finished_tts() { + next_action = parseInt(document.getElementById("reader").getAttribute("action_id"))+1; + action_count = parseInt(document.getElementById("action_count").textContent); + if (next_action <= action_count) { + document.getElementById("reader").src = "/audio?id="+next_action; + document.getElementById("reader").setAttribute("action_id", next_action); + document.getElementById("reader").play(); + document.getElementById("play_tts").textContent = "pause"; + } else { + document.getElementById("play_tts").textContent = "play_arrow"; + } +} + function view_selection_probabilities() { // Not quite sure how this should work yet. Probabilities are obviously on // the token level, which we have no UI representation of. There are other diff --git a/templates/settings flyout.html b/templates/settings flyout.html index f2fa6e3b..69234c06 100644 --- a/templates/settings flyout.html +++ b/templates/settings flyout.html @@ -84,7 +84,7 @@
-
{% with menu='Home' %}