Text to Speech in iOS7
iOS7 makes Text to Speech really easy and that also in multiple languages.
iOS7 has added two new classes for Text to Speech functionality:
1. AVSpeechSynthesizer
2. AVSpeechUtterance
First Link AVFoundation and AudioToolbox Framework from Application Target -> Build Phases -> Link Binary With Libraries.
Import both frameworks in Header file (.h file)
#import <AVFoundation/AVFoundation.h>
#import <AudioToolbox/AudioToolbox.h>
add delegate <AVSpeechSynthesizerDelegate>.
In implementation file (.m file)
AVSpeechSynthesizer *speechSynthesizer = [[AVSpeechSynthesizer alloc] init];
AVSpeechUtterance *speechUtterance = [AVSpeechUtterance speechUtteranceWithString:@"Welcome to iOS App."];
speechUtterance.rate = AVSpeechUtteranceMaximumSpeechRate / 4.0f;
speechUtterance.voice = [AVSpeechSynthesisVoice voiceWithLanguage:@"en-US"]; // language
[speechSynthesizer speakUtterance: speechUtterance];
By adding the above code you can add text to speech functionality to your iOS7 app.
iOS7 has added two new classes for Text to Speech functionality:
1. AVSpeechSynthesizer
2. AVSpeechUtterance
First Link AVFoundation and AudioToolbox Framework from Application Target -> Build Phases -> Link Binary With Libraries.
Import both frameworks in Header file (.h file)
#import <AVFoundation/AVFoundation.h>
#import <AudioToolbox/AudioToolbox.h>
add delegate <AVSpeechSynthesizerDelegate>.
In implementation file (.m file)
AVSpeechSynthesizer *speechSynthesizer = [[AVSpeechSynthesizer alloc] init];
AVSpeechUtterance *speechUtterance = [AVSpeechUtterance speechUtteranceWithString:@"Welcome to iOS App."];
speechUtterance.rate = AVSpeechUtteranceMaximumSpeechRate / 4.0f;
speechUtterance.voice = [AVSpeechSynthesisVoice voiceWithLanguage:@"en-US"]; // language
[speechSynthesizer speakUtterance: speechUtterance];
By adding the above code you can add text to speech functionality to your iOS7 app.
Comments
Post a Comment