'AVSpeechUtterance en-US voice sounds garbled on iOS 12
I have an app that uses AVSpeechUtterance which has been working fine until iOS 12. It still works but the en-US voice sounds garbled. This doesnt happen on the xcode simulator or on the new iPhone XS Max. It seems to only happen on iPhone X. Removing and re-installing the app does not fix the problem. The only fix was to change the voice to en-IE. Has anyone else experienced this or found a workaround??
AVSpeechUtterance *utterance = [[AVSpeechUtterance alloc] initWithString:@"This is a test"];
utterance.voice = [AVSpeechSynthesisVoice voiceWithLanguage:@"en-US"];
utterance.rate = AVSpeechUtteranceDefaultSpeechRate;
[self.synthesizer speakUtterance:utterance];
Solution 1:[1]
iOS12 Made 'en-US' use Fred instead of Samantha,
Try to replace:
utterance.voice = [AVSpeechSynthesisVoice voiceWithLanguage:@"en-US"];
With:
utterance.voice = [AVSpeechSynthesisVoice voiceWithIdentifier:@"com.apple.ttsbundle.Samantha-compact"];
Solution 2:[2]
macOS 12.3 monterey with FRED voice — i had a similar question — only i was unable to obtain the Fred voice. it would keep overriding with the Alex voice (which I did not want). thank you for the above tip — which allowed me to derive the correct syntax to get the voice > identifier and the identifier string to obtain Fred:
mouseCount = Int.random(in: 1..<numPhrases)
let mouseCountStr : String = mousePhrases[mouseCount]
let utterance = AVSpeechUtterance(string: mouseCountStr)
utterance.voice = AVSpeechSynthesisVoice(identifier:"com.apple.speech.synthesis.voice.Fred")
utterance.volume = 0.75
synthesizer.delegate = self
synthesizer.speak(utterance)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Mute Dan |
| Solution 2 | johnrpenner |
