From 58d8b03c59ebfca553cd6f4363ad10b2b153fcc4 Mon Sep 17 00:00:00 2001 From: Bel LaPointe <153096461+breel-render@users.noreply.github.com> Date: Wed, 15 Oct 2025 00:20:54 -0600 Subject: [PATCH] wss or ws --- src/public/index.html | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/src/public/index.html b/src/public/index.html index 566d0d9..499947c 100644 --- a/src/public/index.html +++ b/src/public/index.html @@ -57,7 +57,7 @@ } } - ws = new WebSocket("ws://"+window.location.host+"/ws"+window.location.search); + ws = new WebSocket(`${window.location.protocol == "https:" ? "wss" : "ws"}://${window.location.host}/ws${window.location.search}`); ws.onopen = function(evt) { print("READY"); } @@ -69,21 +69,25 @@ console.log("evt.data:", evt.data) const data = JSON.parse(evt.data); - const utterThis = new SpeechSynthesisUtterance(data.Text); + if (data.Text) { + const utterThis = new SpeechSynthesisUtterance(data.Text); - const idx = data.VoiceIdx || 0; - utterThis.voice = voices[idx]; + const idx = data.VoiceIdx || 0; + utterThis.voice = voices[idx]; - if (data.Pitch) { - utterThis.pitch = data.Pitch + if (data.Pitch) { + utterThis.pitch = data.Pitch + } + + if (data.Rate) { + utterThis.rate = data.Rate + } + + window.speechSynthesis.speak(utterThis); + print(data.Text); + } else if (data.QuietText) { + print(data.QuietText); } - - if (data.Rate) { - utterThis.rate = data.Rate - } - - window.speechSynthesis.speak(utterThis); - print(data.Text); } ws.onerror = function(evt) { print("ERROR: " + evt.data);