Apple added lots of new useful API’s in iOS 7, I am going to speak about one quickly today, AVSpeechSynthesizer.
In short, this is Text to Speech, a really simple way to have iOS read a piece of text out loud. There are a number of use cases for this, navigation, directions, visual impairments, introductions etc.
This framework is very easy to implement, the source code for this example is available on my GitHub .
Firstly you will need to include 2 Frameworks in your project (AudioToolbox.framework and AVFoundation.framework)
The simplest implementation of Text To Speech is only a few lines of code, in this example you could test this by adding the following code to your ViewDidLoad method, make sure that you have imported the AVFramework into your header file (#import <AVFoundation/AVFoundation.h>).
AVSpeechSynthesizer *synthesizer = [[AVSpeechSynthesizer alloc]init]; AVSpeechUtterance *utterance = [AVSpeechUtterance speechUtteranceWithString:@"Some random text that you want to be spoken"]; [utterance setRate:1.1f]; [synthesizer speakUtterance:utterance];
Easy isn’t it?
Find the full source code on GitHub , this will show you how to read from a text-box and also to increase and decrease the speed at which the text is spoken.