I am currently creating an app where I need the app to speak what the user has entered.
Example: if user entered the word cat
I need the app to say cat
.
I am using Xcode 5. Any help will be greatly appreciated. If you understand it would be kind of like a dictation app.
first import <AVFoundation/AVFoundation.h>
the you need an AVSpeechSynthesizer
:
AVSpeechSynthesizer *synthesizer = [[AVSpeechSynthesizer alloc] init];
and can use AVSpeechUtterance
to speak strings:
AVSpeechUtterance *utterance = [[AVSpeechUtterance alloc] initWithString:@"textToSpeak"];
//adjust the speed
utterance.rate = AVSpeechUtteranceDefaultSpeechRate;
//set the language
utterance.voice = [AVSpeechSynthesisVoice voiceWithLanguage:@"en-us"];
//speak it
[self.synthesizer speakUtterance:utterance];