iOS text to speech: What decides the default voice

2019-03-30 23:49发布

问题:

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.

回答1:

[NO Solution yet] I met the same issue, too.

First, set different voice via

Accessibility -> Speech -> Voices
or 
Accessibility -> VoiceOver -> Speech -> Voices

Then

AVSpeechSynthesisVoice(language: language)

It won't affect AVSpeechSynthesizer in iOS 12.0.1 (it works on iOS 11.x & iOS 12.0.0)

I also found two other things on iOS 12.0.1

First, the Siri voice is no longer available when using

AVSpeechSynthesisVoice(identifier: "com.apple.ttsbundle.siri_male_ja-JP_compact")

Second, if I don't set voice identifier, Female Siri in that locale will speak the text. It also doesn't affect by the speech settings in preference. BTW, I still cannot find anyway to make Male Siri Speak anything, yet... haha