iOS Developer Library

Developer

AVFoundation Framework Reference AVSpeechSynthesisVoice Class Reference

Options
Deployment Target:

On This Page
Language:

AVSpeechSynthesisVoice

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

Inheritance


Import Statement


import AVFoundation @import AVFoundation;

Availability


Available in iOS 7.0 and later.
  • Returns a voice object for the specified language and locale.

    Declaration

    Swift

    init!(language language: String!) -> AVSpeechSynthesisVoice

    Objective-C

    + (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.

    Import Statement

    import AVFoundation

    Availability

    Available in iOS 7.0 and later.

  • Returns all available speech voices.

    Declaration

    Swift

    class func speechVoices() -> [AnyObject]!

    Objective-C

    + (NSArray *)speechVoices

    Return Value

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

    Discussion

    Use the language property to differentiate between returned voices.

    Import Statement

    import AVFoundation

    Availability

    Available in iOS 7.0 and later.

  • Returns the code for the user’s current locale.

    Declaration

    Swift

    class func currentLanguageCode() -> String!

    Objective-C

    + (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.

    Import Statement

    import AVFoundation

    Availability

    Available in iOS 7.0 and later.

  • language language Property

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

    Declaration

    Swift

    var language: String! { get }

    Objective-C

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

    Import Statement

    import AVFoundation

    Availability

    Available in iOS 7.0 and later.