AVSpeechSynthesizerDelegate Protocol Reference

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

Overview

The AVSpeechSynthesizerDelegate protocol defines methods that the delegate of an AVSpeechSynthesizer object may implement; all methods in this protocol are optional. You can implement these methods to respond to events that occur during speech synthesis.

Delegate messages are sent by the synthesizer for three categories of events:

For the third case, you can implement speechSynthesizer:willSpeakRangeOfSpeechString:utterance: to provide a user interface in which each word is visibly highlighted as it is spoken.

Tasks

Responding to Speech Synthesis Events

Instance Methods

speechSynthesizer:didCancelSpeechUtterance:

Tells the delegate when the synthesizer has canceled speaking an utterance.

- (void)speechSynthesizer:(AVSpeechSynthesizer *)synthesizer didCancelSpeechUtterance:(AVSpeechUtterance *)utterance
Parameters
synthesizer

The synthesizer speaking the utterance that this message applies to.

utterance

The utterance during which speech was canceled.

Discussion

This message is sent only if speech is stopped (using the stopSpeakingAtBoundary: method) while an utterance is being spoken. It is not sent if the synthesizer is currently in a delay between utterances when speech stops. This message is sent only for the utterance currently being spoken, not for utterances yet to be handled.

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

speechSynthesizer:didContinueSpeechUtterance:

Tells the delegate when the synthesizer has resumed speaking an utterance after being paused.

- (void)speechSynthesizer:(AVSpeechSynthesizer *)synthesizer didContinueSpeechUtterance:(AVSpeechUtterance *)utterance
Parameters
synthesizer

The synthesizer speaking the utterance that this message applies to.

utterance

The utterance being spoken.

Discussion

This message is sent upon resuming speech only if speech was paused (using the pauseSpeakingAtBoundary: method) while an utterance was being spoken. It is not sent if the synthesizer was paused during a delay between utterances.

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

speechSynthesizer:didFinishSpeechUtterance:

Tells the delegate when the synthesizer has finished speaking an utterance.

- (void)speechSynthesizer:(AVSpeechSynthesizer *)synthesizer didFinishSpeechUtterance:(AVSpeechUtterance *)utterance
Parameters
synthesizer

The synthesizer speaking the utterance that this message applies to.

utterance

The utterance that has finished being spoken.

Discussion

This message is sent immediately when speech ends; it is not postponed if the final utterance’s postUtteranceDelay is greater than zero.

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

speechSynthesizer:didPauseSpeechUtterance:

Tells the delegate when the synthesizer has paused while speaking an utterance.

- (void)speechSynthesizer:(AVSpeechSynthesizer *)synthesizer didPauseSpeechUtterance:(AVSpeechUtterance *)utterance
Parameters
synthesizer

The synthesizer speaking the utterance that this message applies to.

utterance

The utterance being spoken.

Discussion

This message is sent only if speech is paused (using the pauseSpeakingAtBoundary: method) while an utterance is being spoken. It is not sent if the synthesizer is currently in a delay between utterances when speech pauses.

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

speechSynthesizer:didStartSpeechUtterance:

Tells the delegate when the synthesizer has begun speaking an utterance.

- (void)speechSynthesizer:(AVSpeechSynthesizer *)synthesizer didStartSpeechUtterance:(AVSpeechUtterance *)utterance
Parameters
synthesizer

The synthesizer speaking the utterance that this message applies to.

utterance

The utterance that has begun to be spoken.

Discussion

If the value of the utterance’s preUtteranceDelay property is grreater than zero, the message is not sent until the delay period has passed and speech has actually begun.

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

speechSynthesizer:willSpeakRangeOfSpeechString:utterance:

Tells the delegate when the synthesizer is about to speak a portion of an utterance’s text.

- (void)speechSynthesizer:(AVSpeechSynthesizer *)synthesizer willSpeakRangeOfSpeechString:(NSRange)characterRange utterance:(AVSpeechUtterance *)utterance
Parameters
synthesizer

The synthesizer speaking the utterance that this message applies to.

characterRange

The range of characters in the utterance’s speechString corresponding to the unit of speech about to be spoken.

utterance

The utterance currently being spoken.

Discussion

Because this delegate message is sent once for each unit of speech (generally, a word) in the utterance’s text, you can use it for such purposes as highlighting each word onscreen as it is spoken.

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