Search code examples
iosavspeechsynthesizer

With AVSpeechSynthesizer can you change the way words or phrases are spoken?


Are there any methods or undocumented tricks for changing the way words or phrases are spoken by the AVSpeechSynthesizer? I am not asking about changing the pitch of the entire sentence or the rate at which it is spoken. I am wanting to change the voice inflection or the intonation of certain parts of a sentence.

If not, what are some SDKs or APIs that do allow for this?


Solution

  • An AVSpeechUtterance allows you to set the rate, pitch, etc. You can create small utterances for, say, each word, and pass those to an AVSpeechSynthesizer, which maintains a queue of utterances to speak. (In other words, you can call speakUtterance: for all of your utterances and it will say them one after another.)

    For an example of this technique, check out this blog post. Note that the level of control here is not great; you can't really control inflection, for example, but you can control pauses, pitch, and so on on a per-word basis.