Skip to content

Commit

Permalink
TTS improved
Browse files Browse the repository at this point in the history
  • Loading branch information
Concedo authored and Concedo committed Nov 9, 2023
1 parent 8ecf21f commit 48a5d17
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3292,6 +3292,7 @@
persist_session: true,
speech_synth: 0, //0 is disabled
beep_on: false,
narrate_both_sides: false,
image_styles: "",
grammar:"",
tokenstreammode: (localflag?1:0), //0=off,1=pollstream,2=sse
Expand Down Expand Up @@ -7002,6 +7003,7 @@
document.getElementById("ttsselect").innerHTML = ttshtml;
document.getElementById("ttsselect").value = localsettings.speech_synth;
document.getElementById("beep_on").checked = localsettings.beep_on;
document.getElementById("narrate_both_sides").checked = localsettings.narrate_both_sides;
toggle_opmode();

//sd models display
Expand Down Expand Up @@ -7178,6 +7180,7 @@

localsettings.speech_synth = document.getElementById("ttsselect").value;
localsettings.beep_on = (document.getElementById("beep_on").checked?true:false);
localsettings.narrate_both_sides = (document.getElementById("narrate_both_sides").checked?true:false);
localsettings.auto_ctxlen = (document.getElementById("auto_ctxlen").checked ? true : false);
localsettings.auto_genamt = (document.getElementById("auto_genamt").checked ? true : false);

Expand Down Expand Up @@ -7901,9 +7904,12 @@
idle_timer = 0;
idle_triggered_counter = 0;
if (localsettings.speech_synth > 0 && 'speechSynthesis' in window) {
let utterance = new window.SpeechSynthesisUtterance(newgen);
utterance.voice = window.speechSynthesis.getVoices()[localsettings.speech_synth - 1];
window.speechSynthesis.speak(utterance);
if(localsettings.narrate_both_sides)
{
let utterance = new window.SpeechSynthesisUtterance(newgen);
utterance.voice = window.speechSynthesis.getVoices()[localsettings.speech_synth - 1];
window.speechSynthesis.speak(utterance);
}
}

if (localsettings.opmode == 4)
Expand Down Expand Up @@ -9181,6 +9187,7 @@
}
}

let gentxtspeak = gentxt;
if (pending_context_preinjection != "") {
if(gentxt!="" && gentxt[0]!=" " && localsettings.opmode==3)
{
Expand All @@ -9191,8 +9198,13 @@
pending_context_preinjection = "";
}

if (localsettings.speech_synth > 0 && 'speechSynthesis' in window) {
let utterance = new window.SpeechSynthesisUtterance(gentxt);
if (localsettings.speech_synth > 0 && 'speechSynthesis' in window)
{
if(localsettings.narrate_both_sides)
{
gentxtspeak = gentxt;
}
let utterance = new window.SpeechSynthesisUtterance(gentxtspeak);
utterance.voice = window.speechSynthesis.getVoices()[localsettings.speech_synth - 1];
window.speechSynthesis.speak(utterance);
}
Expand Down Expand Up @@ -12041,6 +12053,10 @@
<select class="form-control" id="ttsselect" style="height:20px;padding:0;margin:0px 0 0;">
</select>
</div>
<div class="settinglabel">
<div class="justifyleft settingsmall" title="If unchecked, only speak AI replies, not other text.">Narrate Both Sides </div>
<input type="checkbox" id="narrate_both_sides" style="margin:0px 0 0;">
</div>
<div class="settinglabel">
<div class="justifyleft settingsmall" title="Play a sound when generation is complete">Beep on Done </div>
<input type="checkbox" id="beep_on" style="margin:0px 0 0;">
Expand Down

0 comments on commit 48a5d17

Please sign in to comment.