AVSpeechUtterance 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 AVSpeechUtterance is the basic unit of speech synthesis. An utterance encapsulates some amount of text to be spoken and a set of parameters affecting its speech: voice, pitch, rate, and delay.

To synthesize speech, you must:

  1. Create an AVSpeechUtterance instance containing the text to be spoken. (See “Creating an Utterance.”)

  2. (Optional) Change its voice, rate, or other parameters. (See “Configuring Utterance Speech.”)

  3. Pass the utterance to an AVSpeechSynthesizer instance to begin speech (or enqueue the utterance to be spoken later if the synthesizer is already speaking).

You may choose whether and how to split a body of text into multiple utterances for speech. Because an utterance can control speech parameters, you can split text into sections that require different parameters. For example, you can emphasize a sentence by increasing the pitch and decreasing the rate of that utterance relative to others, or you can introduce pauses between sentences by putting each one into an utterance with a leading or trailing delay. Because the speech synthesizer sends messages to its delegate as it starts or finishes speaking an utterance, you can create an utterance for each meaningful unit in a longer text in order to be notified as its speech progresses.

Tasks

Creating an Utterance

Configuring Utterance Speech

Properties

pitchMultiplier

The baseline pitch at which the utterance will be spoken.

@property(nonatomic) float pitchMultiplier
Discussion

The default pitch is 1.0. Allowed values are in the range from 0.5 (for lower pitch) to 2.0 (for higher pitch).

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

postUtteranceDelay

The amount of time a speech synthesizer will wait after the utterance is spoken before handling the next queued utterance.

@property(nonatomic) NSTimeInterval postUtteranceDelay
Discussion

When two or more utterances are spoken by an instance of AVSpeechSynthesizer, the time between periods when either is audible will be at least the sum of the first utterance’s postUtteranceDelay and the second utterance’s preUtteranceDelay.

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

preUtteranceDelay

The amount of time a speech synthesizer will wait before actually speaking the utterance upon beginning to handle it.

@property(nonatomic) NSTimeInterval preUtteranceDelay
Discussion

When two or more utterances are spoken by an instance of AVSpeechSynthesizer, the time between periods when either is audible will be at least the sum of the first utterance’s postUtteranceDelay and the second utterance’s preUtteranceDelay.

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

rate

The rate at which the utterance will be spoken.

@property(nonatomic) float rate
Discussion

Speech rates are values in the range between AVSpeechUtteranceMinimumSpeechRate and AVSpeechUtteranceMaximumSpeechRate. Lower values correspond to slower speech, and vice versa. The default value is AVSpeechUtteranceDefaultSpeechRate.

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

speechString

The text to be spoken in the utterance. (read-only)

@property(nonatomic, readonly) NSString *speechString
Discussion

An utterance’s text cannot be changed once it is created. To speak different text, create a new utterance.

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

voice

The voice used to speak the utterance.

@property(nonatomic, retain) AVSpeechSynthesisVoice *voice
Discussion

The default value is nil, which causes the utterance to be spoken in the default voice.

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

volume

The volume used when speaking the utterance.

@property(nonatomic) float volume
Discussion

Allowed values are in the range from 0.0 (silent) to 1.0 (loudest). The default volume is 1.0.

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

Class Methods

speechUtteranceWithString:

Creates an utterance object with text to be spoken.

+ (AVSpeechUtterance *)speechUtteranceWithString:(NSString *)string
Parameters
string

A string containing text to be spoken.

Return Value

An AVSpeechUtterance object that can speak the specified text.

Discussion

To speak the text, the utterance must be passed to an instance of AVSpeechSynthesizer.

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

Instance Methods

initWithString:

Initializes an utterance object with text to be spoken.

- (AVSpeechUtterance *)initWithString:(NSString *)string
Parameters
string

A string containing text to be spoken.

Return Value

An AVSpeechUtterance object that can speak the specified text.

Discussion

To speak the text, the utterance must be passed to an instance of AVSpeechSynthesizer.

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

Constants

Speech Rate Constants

Constance specifying the range of allowed rates for synthesized speech.

const float AVSpeechUtteranceMinimumSpeechRate;
const float AVSpeechUtteranceMaximumSpeechRate;
const float AVSpeechUtteranceDefaultSpeechRate;
Constants
AVSpeechUtteranceMinimumSpeechRate

The minimum allowed speech rate.

Available in iOS 7.0 and later.

Declared in AVSpeechSynthesis.h.

AVSpeechUtteranceMaximumSpeechRate

The maximum allowed speech rate.

Available in iOS 7.0 and later.

Declared in AVSpeechSynthesis.h.

AVSpeechUtteranceDefaultSpeechRate

The default rate at which an utterance is spoken unless its rate property is changed.

Available in iOS 7.0 and later.

Declared in AVSpeechSynthesis.h.