I've got a speech.synthesis web app that works well, but I want to change some text to a male voice and vice-versa. It works perfectly in Chrome and Mac desktops but for the life of me I can't get it to work on mobile ios (iPhone 11.3.1), both iphone and ipad. Here's the relevant bit (react):
createSpeech(text) {
let speech = new SpeechSynthesisUtterance(text);
let gender = this.state.gender;
speech.volume = 1;
speech.rate = 1;
speech.pitch = 1;
speech.lang = 'en-US';
speech.voice = voices[gender];
speech.voiceURI = voices[gender].voiceURI;
return speech;
}
The voices are loaded (one male, and one female) into a variable called voices. This is working. Then the above bit is run on each sentence.
Again, this works perfectly in Chrome and Mac desktops that I tested. On my iPhone, however, I always get the default voice that has been set on the phone itself.
The weird thing is that I can switch to a different language other than english, say italian or spanish, and get the correct voice, but English always only plays as the internally set default voice.
Does anybody know WHY this is happening? Is it a bug? Am I missing something? Has anybody gotten iphone to get a different voice in english other than the one set?