diff options
author | Nat Lasseter <user@4574.co.uk> | 2022-06-15 22:45:00 +0100 |
---|---|---|
committer | Nat Lasseter <user@4574.co.uk> | 2022-06-15 22:45:00 +0100 |
commit | 603eeadf6d3a2fedbff62fe90e2f89a1584f1fa4 (patch) | |
tree | 63a553fefc66cf392836ad07560449f863934062 | |
parent | eb0989f6c2310d48bfcf93a20f7ff3651e41647b (diff) |
Utter faster
-rw-r--r-- | planed.html | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/planed.html b/planed.html index 5483f0a..09f32e5 100644 --- a/planed.html +++ b/planed.html @@ -32,11 +32,16 @@ div.msg { <div id="overlay"></div> <div id="log"></div> <script> + Array.prototype.sample = function(){ + return this[Math.floor(Math.random()*this.length)]; + } + let ws = new WebSocket("ws://plane.4574.co.uk:80"); let div = document.getElementById("log"); let loglen = 0; const logmax = 18; const timemax = 5000; + const voices = speechSynthesis.getVoices(); ws.onmessage = function(ev) { loglen += 1; @@ -44,7 +49,10 @@ div.msg { if (loglen > logmax) document.getElementById("msg" + (loglen - logmax)).remove(); - speechSynthesis.speak(new SpeechSynthesisUtterance(ev.data)); + let utter = new SpeechSynthesisUtterance(ev.data); + utter.voice = voices.sample(); + utter.rate = 1.2; + speechSynthesis.speak(utter); }; function rantime() { |