AVSpeechSynthesisVoice Class Reference

Inherits from
Conforms to
Framework
/System/Library/Frameworks/AVFoundation.framework
Availability
Available in iOS 7.0 and later.
Companion guide
Declared in
AVSpeechSynthesis.h

Overview

An AVSpeechSynthesisVoice object defines a distinct voice for use in speech synthesis. Voices are distinguished primarily by language and locale.

You can use this class to select a voice appropriate to the language of text to be spoken, or to select a voice exhibiting a particular local variant of that language (such as Australian or South African English).

To select a voice for use in speech, obtain an AVSpeechSynthesisVoice instance using one of the methods in “Finding Voices”, and then set it as the value of the voice property on an AVSpeechUtterance instance containing text to be spoken.

Tasks

Finding Voices

Working with Language Codes

Properties

language

A BCP-47 code identifying the voice’s language and locale. (read-only)

@property(nonatomic, readonly) NSString *language
Discussion

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. The locale of a voice reflects regional variations in pronunciation or accent; for example, a voice with code en-US speaks English text with a North American accent, and a voice with code en-AU speaks English text with an Australian accent.

Availability
  • Available in iOS 7.0 and later.
Declared In
AVSpeechSynthesis.h

Class Methods

currentLanguageCode

Returns the code for the user’s current locale.

+ (NSString *)currentLanguageCode
Return Value

An NSString object containing the BCP-47 language and locale code for the user’s current locale.

Discussion

This code reflects the user’s language and region preferences selected in the Settings app.

Availability
  • Available in iOS 7.0 and later.
Declared In
AVSpeechSynthesis.h

speechVoices

Returns all available speech voices.

+ (NSArray *)speechVoices
Return Value

An array of AVSpeechSynthesisVoice objects, one for each available voice.

Discussion

Use the language property to differentiate between returned voices.

Availability
  • Available in iOS 7.0 and later.
Declared In
AVSpeechSynthesis.h

voiceWithLanguage:

Returns a voice object for the specified language and locale.

+ (AVSpeechSynthesisVoice *)voiceWithLanguage:(NSString *)language
Parameters
language

A BCP-47 code specifying language and locale for a voice.

Return Value

An AVSpeechSynthesisVoice object for the specified language and locale.

Discussion

Returns nil if the language parameter is nil or references a language or locale for which no voice exists.

Availability
  • Available in iOS 7.0 and later.
Declared In
AVSpeechSynthesis.h