Protocol

AVSpeechSynthesizerDelegate

Methods you can implement to respond to events that occur during speech synthesis.

Declaration

protocol AVSpeechSynthesizerDelegate

Overview

All methods in this protocol are optional. An AVSpeechSynthesizer object sends messages to its delegate for three categories of events:

  • When speech pauses or resumes

  • When the synthesizer starts or finishes speaking a block of text (as encapsulated by an AVSpeechUtterance object)

  • As the synthesizer produces each individual unit of speech

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

Topics

Responding to Speech Synthesis Events

func speechSynthesizer(AVSpeechSynthesizer, didCancel: AVSpeechUtterance)

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

func speechSynthesizer(AVSpeechSynthesizer, didContinue: AVSpeechUtterance)

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

func speechSynthesizer(AVSpeechSynthesizer, didFinish: AVSpeechUtterance)

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

func speechSynthesizer(AVSpeechSynthesizer, didPause: AVSpeechUtterance)

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

func speechSynthesizer(AVSpeechSynthesizer, didStart: AVSpeechUtterance)

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

func speechSynthesizer(AVSpeechSynthesizer, willSpeakRangeOfSpeechString: NSRange, utterance: AVSpeechUtterance)

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

Relationships

Inherits From

See Also

Speech Synthesis Controls

class AVSpeechSynthesizer

An object that produces synthesized speech from text utterances and provides controls for monitoring or controlling ongoing speech.