master
parent
13b583a77e
commit
4dd5a40dfe
|
|
@ -2,6 +2,8 @@
|
|||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width" />
|
||||
<script>
|
||||
window.addEventListener("load", function(evt) {
|
||||
var output = document.getElementById("output");
|
||||
|
|
@ -24,6 +26,26 @@
|
|||
ws = null;
|
||||
}
|
||||
ws.onmessage = function(evt) {
|
||||
const synth = window.speechSynthesis;
|
||||
const voices = synth.getVoices().sort(function (a, b) {
|
||||
const aname = a.name.toUpperCase();
|
||||
const bname = b.name.toUpperCase();
|
||||
|
||||
if (aname < bname) {
|
||||
return -1;
|
||||
} else if (aname == bname) {
|
||||
return 0;
|
||||
} else {
|
||||
return +1;
|
||||
}
|
||||
});
|
||||
const idx = false ? 0 : voices.length-1;
|
||||
|
||||
const utterThis = new SpeechSynthesisUtterance(evt.data);
|
||||
utterThis.voice = voices[idx];
|
||||
//utterThis.pitch = 10;
|
||||
//utterThis.rate = 10;
|
||||
window.speechSynthesis.speak(utterThis);
|
||||
print("RESPONSE: " + evt.data);
|
||||
}
|
||||
ws.onerror = function(evt) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue