Today I'm very exited about the speech synthesis function is available in iOS7.
I want to select the male voice(default in OSX, called alex).
I don't know what's the BCP-47 code for him, and BTW how to get the full list of all voice code
iOS 8 added Hebrew, no new languages were added in iOS 9 to 12:
ar-SA Arabic Saudi Arabia
cs-CZ Czech Czech Republic
da-DK Danish Denmark
de-DE German Germany
el-GR Modern Greek Greece
en-AU English Australia
en-GB English United Kingdom
en-IE English Ireland
en-US English United States
en-ZA English South Africa
es-ES Spanish Spain
es-MX Spanish Mexico
fi-FI Finnish Finland
fr-CA French Canada
fr-FR French France
he-IL Hebrew Israel
hi-IN Hindi India
hu-HU Hungarian Hungary
id-ID Indonesian Indonesia
it-IT Italian Italy
ja-JP Japanese Japan
ko-KR Korean Republic of Korea
nl-BE Dutch Belgium
nl-NL Dutch Netherlands
no-NO Norwegian Norway
pl-PL Polish Poland
pt-BR Portuguese Brazil
pt-PT Portuguese Portugal
ro-RO Romanian Romania
ru-RU Russian Russian Federation
sk-SK Slovak Slovakia
sv-SE Swedish Sweden
th-TH Thai Thailand
tr-TR Turkish Turkey
zh-CN Chinese China
zh-HK Chinese Hong Kong
zh-TW Chinese Taiwan
edit: Here is how to print the above in Swift:
func printLanguages() {
AVSpeechSynthesisVoice.speechVoices().forEach { (voice) in
let language = Locale.current.localizedString(forLanguageCode: voice.language)!
let components = Locale.components(fromIdentifier: voice.language)
let country = Locale.current.localizedString(forRegionCode: components["kCFLocaleCountryCodeKey"]!)!
print("\(voice.language) \t \(language) \t\t \(country)")
}
}
You need to import AVFoundation
Here's how to get the BCP-47 codes of the available voices:
for (AVSpeechSynthesisVoice *voice in [AVSpeechSynthesisVoice speechVoices]) {
NSLog(@"%@", voice.language);
}
Alex's locale is "English - United States" (en-US), as you can see in the Dictation & Speech control panel on OS X. (Click "Customize..." in the "System Voice" drop down.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With