iOS text to speech: What decides the default voice returned by [AVSpeechSynthesisVoice voiceWithLanguage]?

Hi,


AVSpeechSynthesisVoice.voiceWithLanguage has been introduced in iOS SDK 7.0. At that time, there is only one voice per language/locale.

Since iOS SDK 9.0, more voices have been added for each language/locale. So Apple introduces an new API voiceWithIdentifier so you can get the specific voice you want.


My question here is, what if we still use voiceWithLanguage in iOS 9 or above. What does this API exactly returns? And more importantly, does the returned voice changed between iOS versions and even between different devices?


I've noticed that, what voiceWithLanguage returns is kind of relying on the iOS speech settings "ettings -> General -> Accessibility -> Speech -> Voices -> English". But not really exact match. That is to say, for example English US, if you set voice "Fred" voiceWithLanguage will return "Fred", which is cool. But if you set voice to "Nicky", voiceWithLanguage returns something else other than "Nicky".


I'm asking this is because my application is using voiceWithLanguage. And while user upgraded iOS to iOS 12, they reported that they heard a difference voice. I believe voiceWithLanguage is returning a different voice after upgrading to iOS 12. While I can't reproduce it on the same type of devices.


And of course I can start to use voiceWithIdentifier instead. But just curious about this voiceWithLanguage.

The language of a voice controls the conversion of text to spoken phonemes, so the text spoken in an AVSpeechUtterance should be written in the language matching that of the voice assigned to that utterance.


    func showAvailableSpeechVoices(){
        let speechVoices = AVSpeechSynthesisVoice.speechVoices()
        for voice in speechVoices{
            print("\(voice.identifier) \(voice.name) \(voice.quality) \(voice.language)")
        }
    }


Return 38 voices:


com.apple.ttsbundle.Maged-compact Maged AVSpeechSynthesisVoiceQuality ar-SA

com.apple.ttsbundle.Zuzana-compact Zuzana AVSpeechSynthesisVoiceQuality cs-CZ

com.apple.ttsbundle.Sara-compact Sara AVSpeechSynthesisVoiceQuality da-DK

com.apple.ttsbundle.Anna-compact Anna AVSpeechSynthesisVoiceQuality de-DE

com.apple.ttsbundle.Melina-compact Melina AVSpeechSynthesisVoiceQuality el-GR

com.apple.ttsbundle.Karen-compact Karen AVSpeechSynthesisVoiceQuality en-AU

com.apple.ttsbundle.Daniel-compact Daniel AVSpeechSynthesisVoiceQuality en-GB

com.apple.ttsbundle.Moira-compact Moira AVSpeechSynthesisVoiceQuality en-IE

com.apple.speech.synthesis.voice.Fred Fred AVSpeechSynthesisVoiceQuality en-US

com.apple.ttsbundle.Samantha-compact Samantha AVSpeechSynthesisVoiceQuality en-US

com.apple.ttsbundle.Tessa-compact Tessa AVSpeechSynthesisVoiceQuality en-ZA

com.apple.ttsbundle.Monica-compact Monica AVSpeechSynthesisVoiceQuality es-ES

com.apple.ttsbundle.Paulina-compact Paulina AVSpeechSynthesisVoiceQuality es-MX

com.apple.ttsbundle.Satu-compact Satu AVSpeechSynthesisVoiceQuality fi-FI

com.apple.ttsbundle.Amelie-compact Amelie AVSpeechSynthesisVoiceQuality fr-CA

com.apple.ttsbundle.Thomas-compact Thomas AVSpeechSynthesisVoiceQuality fr-FR

com.apple.ttsbundle.Carmit-compact Carmit AVSpeechSynthesisVoiceQuality he-IL

com.apple.ttsbundle.Lekha-compact Lekha AVSpeechSynthesisVoiceQuality hi-IN

com.apple.ttsbundle.Mariska-compact Mariska AVSpeechSynthesisVoiceQuality hu-HU

com.apple.ttsbundle.Damayanti-compact Damayanti AVSpeechSynthesisVoiceQuality id-ID

com.apple.ttsbundle.Alice-compact Alice AVSpeechSynthesisVoiceQuality it-IT

com.apple.ttsbundle.Kyoko-compact Kyoko AVSpeechSynthesisVoiceQuality ja-JP

com.apple.ttsbundle.Yuna-compact Yuna AVSpeechSynthesisVoiceQuality ko-KR

com.apple.ttsbundle.Ellen-compact Ellen AVSpeechSynthesisVoiceQuality nl-BE

com.apple.ttsbundle.Xander-compact Xander AVSpeechSynthesisVoiceQuality nl-NL

com.apple.ttsbundle.Nora-compact Nora AVSpeechSynthesisVoiceQuality no-NO

com.apple.ttsbundle.Zosia-compact Zosia AVSpeechSynthesisVoiceQuality pl-PL

com.apple.ttsbundle.Luciana-compact Luciana AVSpeechSynthesisVoiceQuality pt-BR

com.apple.ttsbundle.Joana-compact Joana AVSpeechSynthesisVoiceQuality pt-PT

com.apple.ttsbundle.Ioana-compact Ioana AVSpeechSynthesisVoiceQuality ro-RO

com.apple.ttsbundle.Milena-compact Milena AVSpeechSynthesisVoiceQuality ru-RU

com.apple.ttsbundle.Laura-compact Laura AVSpeechSynthesisVoiceQuality sk-SK

com.apple.ttsbundle.Alva-compact Alva AVSpeechSynthesisVoiceQuality sv-SE

com.apple.ttsbundle.Kanya-compact Kanya AVSpeechSynthesisVoiceQuality th-TH

com.apple.ttsbundle.Yelda-compact Yelda AVSpeechSynthesisVoiceQuality tr-TR

com.apple.ttsbundle.Ting-Ting-compact Ting-Ting AVSpeechSynthesisVoiceQuality zh-CN

com.apple.ttsbundle.Sin-Ji-compact Sin-Ji AVSpeechSynthesisVoiceQuality zh-HK

com.apple.ttsbundle.Mei-Jia-compact Mei-Jia AVSpeechSynthesisVoiceQuality zh-TW

iOS text to speech: What decides the default voice returned by [AVSpeechSynthesisVoice voiceWithLanguage]?
 
 
Q