diff options
author | Nat Lasseter <user@4574.co.uk> | 2022-06-15 23:18:19 +0100 |
---|---|---|
committer | Nat Lasseter <user@4574.co.uk> | 2022-06-15 23:18:19 +0100 |
commit | f86bbc75fbc1bd85b08e407474585604050d47fc (patch) | |
tree | 20de7dd02d898af4b8cbee5da34b975ac9e931d2 /planed.html | |
parent | 603eeadf6d3a2fedbff62fe90e2f89a1584f1fa4 (diff) |
I'm not even sorry.
Diffstat (limited to 'planed.html')
-rw-r--r-- | planed.html | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/planed.html b/planed.html index 09f32e5..55c4c77 100644 --- a/planed.html +++ b/planed.html @@ -32,15 +32,12 @@ 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; + while (speechSynthesis === undefined) ; const voices = speechSynthesis.getVoices(); ws.onmessage = function(ev) { @@ -50,7 +47,7 @@ div.msg { document.getElementById("msg" + (loglen - logmax)).remove(); let utter = new SpeechSynthesisUtterance(ev.data); - utter.voice = voices.sample(); + utter.voice = voices[Math.floor(Math.random() * voices.length)]; utter.rate = 1.2; speechSynthesis.speak(utter); }; |