aboutsummaryrefslogtreecommitdiff
path: root/planed.html
diff options
context:
space:
mode:
authorNat Lasseter <user@4574.co.uk>2022-06-16 19:28:52 +0100
committerNat Lasseter <user@4574.co.uk>2022-06-16 19:28:52 +0100
commitdabbd8e956c4af470d0ee00b4eebc4afac278223 (patch)
tree3615543c7329aebc6099f80c40fd644e99c92b9c /planed.html
parent6d780b04f1a651656249645247939312e459bb24 (diff)
Filter voices to English
Diffstat (limited to 'planed.html')
-rw-r--r--planed.html9
1 files changed, 6 insertions, 3 deletions
diff --git a/planed.html b/planed.html
index 4df0f34..177ee2a 100644
--- a/planed.html
+++ b/planed.html
@@ -39,8 +39,12 @@ div.msg {
let loglen = 0;
let voices = [];
speechSynthesis.onvoiceschanged = function() {
- voices = speechSynthesis.getVoices();
- }
+ voices = speechSynthesis.getVoices().filter(
+ function(v) {
+ v.lang.startsWith("en");
+ }
+ );
+ };
ws.onmessage = function(ev) {
loglen += 1;
@@ -51,7 +55,6 @@ div.msg {
let utter = new SpeechSynthesisUtterance(ev.data);
utter.voice = voices[Math.floor(Math.random() * voices.length)];
utter.rate = 1.3;
- utter.lang = 'en-GB';
speechSynthesis.speak(utter);
};