A chunk of text to be spoken, along with parameters that affect its speech.
- iOS 7.0+
- macOS 10.14+
- UIKit for Mac 13.0+Beta
- tvOS 9.0+
- watchOS 2.0+
AVSpeech object is the basic unit of speech synthesis.
To synthesize speech, you must:
AVSpeechinstance containing the text to be spoken. (See Creating an Utterance.)
(Optional) Change its voice (including the language used), rate, or other parameters. (See Configuring Utterance Speech.)
Pass the utterance to an
AVSpeechinstance 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.