Hello, I’m trying to use window.speechSynthesis.getVoices() for my anki project, but it’s always empty. Is there any workaround ?
I cannot use the {{tts…}} thingy because I load my app right into anki:
<div id="siteloader"></div>
<script src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
<script>
$("#siteloader").html('<object data="http://localhost:3001/word/{{Word}}>');
</script>
In my app I use the node package speak-tts - because I was too lazy to code some of the features it provides - but, long story short, here’s what it does - and what I need to work - :
function speak(word) {
const speech = new SpeechSynthesisUtterance();
speech.text = word;
speech.volume = 1; // 0 to 1
speech.rate = 1; // 0.1 to 9
speech.pitch = 1; // 0 to 2, 1=normal
speech.voice = typeof window !== 'undefined' && window.speechSynthesis.getVoices().filter((v) => v.lang == 'ja-JP')[0];
speechSynthesis.cancel();
speechSynthesis.speak(speech);
}
The TTS works in my browser but won’t in anki, so I’m guessing the issue lies within what chromium flags anki uses.