I'm playing around with AVSpeechSynthesizer and always getting these errors:
ERROR: >aqsrv> 65: Exception caught in (null) - error -66634
ERROR: AVAudioSessionUtilities.h:88: GetProperty_DefaultToZero: AudioSessionGetProperty ('disa') failed with error: '?ytp'
My code is:
AVSpeechSynthesizer *synthesizer = [[AVSpeechSynthesizer alloc] init];
[synthesizer setDelegate:self];
speechSpeed = AVSpeechUtteranceMinimumSpeechRate;
AVSpeechUtterance *synUtt = [[AVSpeechUtterance alloc] initWithString:[[self text] text]];
[synUtt setRate:speechSpeed];
[synUtt setVoice:[AVSpeechSynthesisVoice voiceWithLanguage:languageCode]];
[synthesizer speakUtterance:synUtt];
Does anyone know how to fix these errors?
I got the code above to work on the simulator with minimal tweaks.
The [[self text] text]
bit of your code might be wrong (which is where the Exception caught in (null)
error would come from). The code below worked for me.
AVSpeechSynthesizer *synthesizer = [[AVSpeechSynthesizer alloc] init];
[synthesizer setDelegate:self]; // set your class to conform to the AVSpeechSynthesizerDelegate protocol
float speechSpeed = AVSpeechUtteranceMinimumSpeechRate;
AVSpeechUtterance *synUtt = [[AVSpeechUtterance alloc] initWithString:@"hello I am testing"];
[synUtt setRate:speechSpeed];
[synUtt setVoice:[AVSpeechSynthesisVoice voiceWithLanguage:[AVSpeechSynthesisVoice currentLanguageCode]]];
[synthesizer speakUtterance:synUtt];
And when I say "worked", I mean I heard the voice uttering my test sentence in my simulator.
I did still see this warning:
2013-09-21 11:37:56.454 Speech[5550:3a03] 11:37:56.454 ERROR: AVAudioSessionUtilities.h:88: GetProperty_DefaultToZero: AudioSessionGetProperty ('disa') failed with error: '?ytp'
Xcode 5 appears to have a heck of a slow time trying to work with the traditional #import <AVFoundation/AVFoundation.h>
with this SpeechSynthesis code, things seemed to speed up quite a bit when using the new @import AVFoundation;
.