Reputation: 81
I am using react and here's some code for TTS(text to speech). It works perfectly well on windows and macOS and some versions of iOS devices. But for some iOS devices, setting the voice just does not work.
<a
className="button"
onClick={() => {
var u = new SpeechSynthesisUtterance();
var voices = speechSynthesis.getVoices();
const voice = voices.filter(voice => {
return voice.lang === "zh-CN";
});
u.voice = voice[0];
u.lang = "zh-CN";
u.text = "1234";
speechSynthesis.speak(u);
}}
>
Speak!!
</a>
Here's what I got from debugging. If I use getVoices(), I can get a lot of voices(including the ones that I want). But setting the lang property or the voice property in the Utterance just does not have any effect. And it will always use the system default voice.
Is this some sort of bug on the iOS system? If so are there any workarounds? Like some sort of components on react?
Upvotes: 0
Views: 316
Reputation: 81
Seems that this problem is specific to iOS 12 system. Had to switch to AWS Polly.
Upvotes: 1