What are the BCP-47 voice codes available for iOS 7 AVSpeechSynthesisVoice?
Asked Answered
H

3

7

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

Hwu answered 15/12, 2013 at 1:26 Comment(1)
do you know if it's possible to add custom voices or where the models for the standard voices are stored in the file system? wondering if there's a way to hack custom voices.Stiff
U
9

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.)

Upcoming answered 15/12, 2013 at 1:47 Comment(1)
do you know if it's possible to add custom voices or where the models for the standard voices are stored in the file system? wondering if there's a way to hack custom voices.Stiff
K
10

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

Kabyle answered 7/10, 2015 at 9:13 Comment(1)
How to get the same list as you are written abovePercolation
U
9

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.)

Upcoming answered 15/12, 2013 at 1:47 Comment(1)
do you know if it's possible to add custom voices or where the models for the standard voices are stored in the file system? wondering if there's a way to hack custom voices.Stiff
M
5

As of iOS 7.1 there are 36 voices for the following BCP-47 codes:

ar-SA
cs-CZ
da-DK
de-DE
el-GR
en-AU
en-GB
en-IE
en-US
en-ZA
es-ES
es-MX
fi-FI
fr-CA
fr-FR
hi-IN
hu-HU
id-ID
it-IT
ja-JP
ko-KR
nl-BE
nl-NL
no-NO
pl-PL
pt-BR
pt-PT
ro-RO
ru-RU
sk-SK
sv-SE
th-TH
tr-TR
zh-CN
zh-HK
zh-TW
Moncrief answered 25/2, 2014 at 11:22 Comment(1)
do you know if it's possible to add custom voices or where the models for the standard voices are stored in the file system? wondering if there's a way to hack custom voices.Stiff

© 2022 - 2024 — McMap. All rights reserved.