Search code examples
iosiphonexcodetext-to-speechavspeechsynthesizer

Applying a filter on the output voice from AVSpeechSynthesizer's Voice?


Is there any way to apply a filter on AVSpeechSynthesizer's voice or changing it's pitch? or even using another TTS API for iOS that we can change the way they sound? or Can we record the TTS voice without it being played and then playing it after the pitch of it's voice has been modified by us?


Solution

  • To use the speech synthesizer you must create an AVSpeechUtterance object. The utterance lets you set a number of properties including pitch. Changing pitch doesn't affect the rate of speech. Example of usage:

        let utterance = AVSpeechUtterance(string: textToSpeak.text!)
        utterance.pitchMultiplier = pitchValue
        utterance.rate = rate.value
        utterance.volume = volume.value
        utterance.voice = voice