wss or ws
parent
9a44380d45
commit
58d8b03c59
|
|
@ -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) {
|
ws.onopen = function(evt) {
|
||||||
print("READY");
|
print("READY");
|
||||||
}
|
}
|
||||||
|
|
@ -69,6 +69,7 @@
|
||||||
console.log("evt.data:", evt.data)
|
console.log("evt.data:", evt.data)
|
||||||
const data = JSON.parse(evt.data);
|
const data = JSON.parse(evt.data);
|
||||||
|
|
||||||
|
if (data.Text) {
|
||||||
const utterThis = new SpeechSynthesisUtterance(data.Text);
|
const utterThis = new SpeechSynthesisUtterance(data.Text);
|
||||||
|
|
||||||
const idx = data.VoiceIdx || 0;
|
const idx = data.VoiceIdx || 0;
|
||||||
|
|
@ -84,6 +85,9 @@
|
||||||
|
|
||||||
window.speechSynthesis.speak(utterThis);
|
window.speechSynthesis.speak(utterThis);
|
||||||
print(data.Text);
|
print(data.Text);
|
||||||
|
} else if (data.QuietText) {
|
||||||
|
print(data.QuietText);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ws.onerror = function(evt) {
|
ws.onerror = function(evt) {
|
||||||
print("ERROR: " + evt.data);
|
print("ERROR: " + evt.data);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue