Now you can make your app speech !
iOS7 introduces the classes
AVSpeechSynthesizer
and AVSpeechUtterance
. Using this two classes to provide speech synsthesis on your app is very easy. See the following code:AVSpeechSynthesizer *synthesizer = [[AVSpeechSynthesizer alloc] init]; AVSpeechUtterance *utterance = [AVSpeechUtterance speechUtteranceWithString:@"Wow, I have such a nice voice!"]; utterance.rate = AVSpeechUtteranceMaximumSpeechRate / 4.0f; utterance.voice = [AVSpeechSynthesisVoice voiceWithLanguage:@"en-US"]; // defaults to your system language [synthesizer speakUtterance:utterance]; |
That is! Only takes five lines of code to add speech to your app.
Cap comentari:
Publica un comentari a l'entrada