16

The standard way to get a list of 'all' AVSpeechSynthesisVoice objects, is to ask for it:

[AVSpeechSynthesisVoice speechVoices]

However, this only shows a unique default voice per language-region pair. e.g. for en-US:

"Language: en-US, Name: Samantha, Quality: Default",

If I look in the Settings app under General → Accessibility → Speech → Voices → English I see that I have 'Siri Female (Enhanced)' selected, but that voice is not selectable from code. The full list is

1

So the big question is: how do I select e.g. Alex or Siri Female as a voice from code?

4 Answers 4

19

Background

  • AVSpeechSynthesisVoice documentation page.

  • Languages for the voices should be specified in BCP-47 format. See below for the available voices, (and what their corresponding BCP-47 language codes mean).

Supported voices

As of 7th May 2020, print(AVSpeechSynthesisVoice.speechVoices()) reports the following supported voices (iOS 13.3.1; iPhone rather than simulator):

[AVSpeechSynthesisVoice 0x28266f9c0] Language: ar-SA, Name: Maged, Quality: Default [com.apple.ttsbundle.Maged-compact]
[AVSpeechSynthesisVoice 0x28266dd10] Language: cs-CZ, Name: Zuzana, Quality: Default [com.apple.ttsbundle.Zuzana-compact]
[AVSpeechSynthesisVoice 0x28266f050] Language: da-DK, Name: Sara, Quality: Default [com.apple.ttsbundle.Sara-compact]
[AVSpeechSynthesisVoice 0x28266ef90] Language: de-DE, Name: Anna, Quality: Default [com.apple.ttsbundle.Anna-compact]
[AVSpeechSynthesisVoice 0x28266f710] Language: de-DE, Name: Helena, Quality: Default [com.apple.ttsbundle.siri_female_de-DE_compact]
[AVSpeechSynthesisVoice 0x28266d8f0] Language: de-DE, Name: Martin, Quality: Default [com.apple.ttsbundle.siri_male_de-DE_compact]
[AVSpeechSynthesisVoice 0x28266fbf0] Language: el-GR, Name: Melina, Quality: Default [com.apple.ttsbundle.Melina-compact]
[AVSpeechSynthesisVoice 0x28266f9b0] Language: en-AU, Name: Catherine, Quality: Default [com.apple.ttsbundle.siri_female_en-AU_compact]
[AVSpeechSynthesisVoice 0x28266ea00] Language: en-AU, Name: Gordon, Quality: Default [com.apple.ttsbundle.siri_male_en-AU_compact]
[AVSpeechSynthesisVoice 0x28266f5e0] Language: en-AU, Name: Karen, Quality: Default [com.apple.ttsbundle.Karen-compact]
[AVSpeechSynthesisVoice 0x28266e9a0] Language: en-GB, Name: Arthur, Quality: Default [com.apple.ttsbundle.siri_male_en-GB_compact]
[AVSpeechSynthesisVoice 0x28266fba0] Language: en-GB, Name: Daniel, Quality: Default [com.apple.ttsbundle.Daniel-compact]
[AVSpeechSynthesisVoice 0x28266f880] Language: en-GB, Name: Martha, Quality: Default [com.apple.ttsbundle.siri_female_en-GB_compact]
[AVSpeechSynthesisVoice 0x28266d0e0] Language: en-IE, Name: Moira, Quality: Default [com.apple.ttsbundle.Moira-compact]
[AVSpeechSynthesisVoice 0x28266efe0] Language: en-IN, Name: Rishi, Quality: Default [com.apple.ttsbundle.Rishi-compact]
[AVSpeechSynthesisVoice 0x2826327e0] Language: en-US, Name: Aaron, Quality: Default [com.apple.ttsbundle.siri_male_en-US_compact]
[AVSpeechSynthesisVoice 0x28266fb40] Language: en-US, Name: Fred, Quality: Default [com.apple.speech.synthesis.voice.Fred]
[AVSpeechSynthesisVoice 0x28266ce30] Language: en-US, Name: Nicky, Quality: Default [com.apple.ttsbundle.siri_female_en-US_compact]
[AVSpeechSynthesisVoice 0x28266ed60] Language: en-US, Name: Samantha, Quality: Default [com.apple.ttsbundle.Samantha-compact]
[AVSpeechSynthesisVoice 0x28266f170] Language: en-ZA, Name: Tessa, Quality: Default [com.apple.ttsbundle.Tessa-compact]
[AVSpeechSynthesisVoice 0x28266ef60] Language: es-ES, Name: Mónica, Quality: Default [com.apple.ttsbundle.Monica-compact]
[AVSpeechSynthesisVoice 0x28266ed30] Language: es-MX, Name: Paulina, Quality: Default [com.apple.ttsbundle.Paulina-compact]
[AVSpeechSynthesisVoice 0x28266d2d0] Language: fi-FI, Name: Satu, Quality: Default [com.apple.ttsbundle.Satu-compact]
[AVSpeechSynthesisVoice 0x28266fe40] Language: fr-CA, Name: Amélie, Quality: Default [com.apple.ttsbundle.Amelie-compact]
[AVSpeechSynthesisVoice 0x28266f620] Language: fr-FR, Name: Daniel, Quality: Default [com.apple.ttsbundle.siri_male_fr-FR_compact]
[AVSpeechSynthesisVoice 0x28266fbc0] Language: fr-FR, Name: Marie, Quality: Default [com.apple.ttsbundle.siri_female_fr-FR_compact]
[AVSpeechSynthesisVoice 0x28266fb20] Language: fr-FR, Name: Thomas, Quality: Default [com.apple.ttsbundle.Thomas-compact]
[AVSpeechSynthesisVoice 0x28266fd30] Language: he-IL, Name: Carmit, Quality: Default [com.apple.ttsbundle.Carmit-compact]
[AVSpeechSynthesisVoice 0x28266d820] Language: hi-IN, Name: Lekha, Quality: Default [com.apple.ttsbundle.Lekha-compact]
[AVSpeechSynthesisVoice 0x28266f070] Language: hu-HU, Name: Mariska, Quality: Default [com.apple.ttsbundle.Mariska-compact]
[AVSpeechSynthesisVoice 0x28266ed70] Language: id-ID, Name: Damayanti, Quality: Default [com.apple.ttsbundle.Damayanti-compact]
[AVSpeechSynthesisVoice 0x282631210] Language: it-IT, Name: Alice, Quality: Default [com.apple.ttsbundle.Alice-compact]
[AVSpeechSynthesisVoice 0x28266ef30] Language: ja-JP, Name: Hattori, Quality: Default [com.apple.ttsbundle.siri_male_ja-JP_compact]
[AVSpeechSynthesisVoice 0x28266d510] Language: ja-JP, Name: Kyoko, Quality: Default [com.apple.ttsbundle.Kyoko-compact]
[AVSpeechSynthesisVoice 0x28266e840] Language: ja-JP, Name: O-ren, Quality: Default [com.apple.ttsbundle.siri_female_ja-JP_compact]
[AVSpeechSynthesisVoice 0x28266ea90] Language: ko-KR, Name: Yuna, Quality: Default [com.apple.ttsbundle.Yuna-compact]
[AVSpeechSynthesisVoice 0x28266f6e0] Language: nl-BE, Name: Ellen, Quality: Default [com.apple.ttsbundle.Ellen-compact]
[AVSpeechSynthesisVoice 0x28266f6a0] Language: nl-NL, Name: Xander, Quality: Default [com.apple.ttsbundle.Xander-compact]
[AVSpeechSynthesisVoice 0x28266dc80] Language: no-NO, Name: Nora, Quality: Default [com.apple.ttsbundle.Nora-compact]
[AVSpeechSynthesisVoice 0x28266d020] Language: pl-PL, Name: Zosia, Quality: Default [com.apple.ttsbundle.Zosia-compact]
[AVSpeechSynthesisVoice 0x28266e930] Language: pt-BR, Name: Luciana, Quality: Default [com.apple.ttsbundle.Luciana-compact]
[AVSpeechSynthesisVoice 0x28266e1b0] Language: pt-PT, Name: Joana, Quality: Default [com.apple.ttsbundle.Joana-compact]
[AVSpeechSynthesisVoice 0x28266cfb0] Language: ro-RO, Name: Ioana, Quality: Default [com.apple.ttsbundle.Ioana-compact]
[AVSpeechSynthesisVoice 0x28266ee50] Language: ru-RU, Name: Milena, Quality: Default [com.apple.ttsbundle.Milena-compact]
[AVSpeechSynthesisVoice 0x28266eee0] Language: sk-SK, Name: Laura, Quality: Default [com.apple.ttsbundle.Laura-compact]
[AVSpeechSynthesisVoice 0x28266e070] Language: sv-SE, Name: Alva, Quality: Default [com.apple.ttsbundle.Alva-compact]
[AVSpeechSynthesisVoice 0x28266d470] Language: th-TH, Name: Kanya, Quality: Default [com.apple.ttsbundle.Kanya-compact]
[AVSpeechSynthesisVoice 0x28266f1d0] Language: tr-TR, Name: Yelda, Quality: Default [com.apple.ttsbundle.Yelda-compact]
[AVSpeechSynthesisVoice 0x28266db10] Language: zh-CN, Name: Tian-Tian (Enhanced), Quality: Enhanced [com.apple.ttsbundle.Ting-Ting-premium]
[AVSpeechSynthesisVoice 0x28266d890] Language: zh-CN, Name: Li-mu, Quality: Default [com.apple.ttsbundle.siri_male_zh-CN_compact]
[AVSpeechSynthesisVoice 0x28266d4c0] Language: zh-CN, Name: Tian-Tian, Quality: Default [com.apple.ttsbundle.Ting-Ting-compact]
[AVSpeechSynthesisVoice 0x28266ea60] Language: zh-CN, Name: Yu-shu, Quality: Default [com.apple.ttsbundle.siri_female_zh-CN_compact]
[AVSpeechSynthesisVoice 0x28266f140] Language: zh-HK, Name: Sin-Ji, Quality: Default [com.apple.ttsbundle.Sin-Ji-compact]
[AVSpeechSynthesisVoice 0x28266ef10] Language: zh-TW, Name: Mei-Jia, Quality: Default [com.apple.ttsbundle.Mei-Jia-compact]
[AVAlexSpeechSynthesisVoice 0x282630950] Language: en-US, Name: Alex, Quality: Enhanced [com.apple.speech.voice.Alex]

As Axello comments below, this evidently does not include the en-AU male voice that is available in the iPhone preferences, "Lee". It would seem that he is not currently available through this API. Perhaps he will be added in time, but given that the available voices don't look like they've changed since 30th December 2015, I wouldn't hold my breath for it.

Setup

import AVFoundation

let utterance : AVSpeechUtterance = AVSpeechUtterance(string: "String to be read out.")
let voiceToUse: AVSpeechSynthesisVoice? = AVSpeechSynthesisVoice(language: "en-US")
utterance.voice = voiceToUse! // Set voice by BCP-47 language code.
AVSpeechSynthesizer().speak(utterance) // Note: Won't be heard in Swift Playground.

Answer

We can select Alex's voice directly, using AVSpeechSynthesisVoice(identifier: AVSpeechSynthesisVoiceIdentifierAlex), but oddly the only identifier that Apple have provided to date is for Alex. 🤷

For any other voices (see the above list again for the voice names), use the following code:

// From https://www.ikiapps.com/tips/2015/12/30/setting-voice-for-tts-in-ios
var voiceToUse: AVSpeechSynthesisVoice?
for voice in AVSpeechSynthesisVoice.speechVoices() {
    if #available(iOS 9.0, *) {
        if voice.name == "Karen" {
            voiceToUse = voice
        }
    } 
}

(This could be done more elegantly using filter() than a loop, but I'm not familiar with the syntax in Swift, so refer here if interested, or leave a comment if you know how to write it).

As for the voices labelled 'Siri', I have no idea. Maybe they're unrelated to AVSpeechSynthesisVoice? Comments welcomed if you know the deal behind them.

5
  • I think I also tried a similar approach, but AVSpeechSynthesisVoice.speechVoices simply does not give you any indication which Karen this is, or if it is enhanced and such. Maybe it works now in iOS 10, but I don't have my hopes up.
    – axello
    Commented Apr 24, 2017 at 22:36
  • @axello I only see one Karen – the one for en-AU – both in speechVoices and in the iPhone preferences. And as far as I can hear (it's pretty distinct for the Mandarin voices), the enhanced voice will be automatically used rather than the normal voice, provided the enhanced voice has been downloaded. Commented Apr 24, 2017 at 23:15
  • Interesting. Here in the iPhone preferences I also see a "Lee" (404MB) download for English (Australia). I did not know it would automatically take the Enhanced voice, as you can select either in the Settings app.
    – axello
    Commented Apr 28, 2017 at 12:35
  • @axello I've updated my answer with an investigation into Lee. Yeah, looks like you just can't use him 🤷 I'd like to double-check whether I'm remembering correctly about enhanced voices being selected automatically and confirm it in the post later – apparently I can't just quickly check in an Swift Playground right now though. Commented Apr 28, 2017 at 13:25
  • I guess I should file a radar for that.
    – axello
    Commented May 3, 2017 at 14:22
6

Following up on Jamie answer (now iOS 11.3 I believe also works with earlier versions):

for the other voices the identifier is structured as "com.apple.ttsbundle.Kanya-compact"

You can get those that are available by:

let voices = AVSpeechSynthesisVoice.speechVoices()
for voice in voices {
    print (voice.identifier + " " + s.language + " " + s.name)
}

and set the voice by either identifier or language.

//set utterance first!
speechUtter = AVSpeechUtterance(string:"أتمنى لك نهارا سعيد")

speechUtter.voice = AVSpeechSynthesisVoice(identifier: "com.apple.ttsbundle.Maged-compact") 

or

speechUtter.voice = AVSpeechSynthesisVoice(language: "ar-SA")
2

You can use this simple command print(AVSpeechSynthesisVoice.speechVoices())

2

While this is an old question, in my observations, the AVSpeechSynthesisVoice.speechVoices() lists all voices that are available on device

If you go into the speech preferences on iPhone

(As of at least iOS 14.5)

Settings -> Accessibility -> Spoken Content -> Voices

enter image description here

In the screen there you can select a language and then additional voices are available for download. I personally downloaded the UK English Daniel (Enhanced) voice, it's very similar to the one included with iOS by default but ehem... enhanced. Incidentally it is listed as Daniel (Enhanced) in the voices list and has an identifier of com.apple.ttsbundle.Daniel-premium

Anyone is welcome to correct me if I'm wrong, but as far as I can tell, there is no way to list any voice that is not downloaded nor is there a way to present a list of voices to download.

I hope this helps some one in the future regarding voices on iOS.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.