Make iOS talk (speech synthesizing)

Reviews | Tutorial By 3 years ago

iOS7 introduced the abiltiy for developers to do speech synthesizing. This means now you can translate text into speech.

It’s quite simple to do:

First import the AVFoundation framework – you may also need to link your project with it as well.

#import <AVFoundation/AVFoundation.h>

Now create an utterance and give it to a speech synthesizer instance:

NSString* textToSpeak = @"Look ma', no hands!";
AVSpeechUtterance* utterance = [[AVSpeechUtterance alloc] initWithString:textToSpeak];

AVSpeechSynthesizer* synthesizer = [[AVSpeechSynthesizer alloc] init];
[synthesizer speakUtterance:utterance];

For the most part that’s it. If you want to do some more advanced stuff, you can adjust the voice, speech rate, and get notifications of how far through speaking your synthesizer is.

  • Mouhamed Assafiri

    Wow that’s too easy. What about using a Speech To Text library, like OpenEars. Any reviews on that?

    • Tom

      I haven’t used any others before. It would be interesting comparing how realistic other libraries are compared to Apple’s.

      • myRepoSpace

        Does the Apple’s SDK provide a Speech to Text framework?

        • Tom

          Sorry I thought you said text to speech, nope they don’t offer that.