Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AVSpeechSynthesizer error AudioSession

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?

like image 817
h345k34cr Avatar asked Sep 21 '13 18:09

h345k34cr


3 Answers

I got the code above to work on the simulator with minimal tweaks.

  1. 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'

  2. 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;.

like image 66
Michael Dautermann Avatar answered Oct 28 '22 15:10

Michael Dautermann


I see these errors too (using ARC but not muli threaded) but only on the simulator, not on a real device.

I am working on the assumption that they are a simulator limitation and can be safely ignored - everything else seems to be working fine.

Ali

like image 22
Ali Beadle Avatar answered Oct 28 '22 15:10

Ali Beadle


I get exactly the same error log in the Simulator but I have no problem with the code in either the Simulator or on the iPhone 5 device as you've indicated elsewhere. The difference might be that I'm not using any of those 6 optional AVSpeechSythesizerDelegates and consequently, I have not included it in my class protocol. Hence, to help track your error, you might try it without. Here is my test code, which is logically the same as yours, minus the delegate and any AVSpeechUtterance storage allocation:

-(void)tts:(NSString*)text
{

#define MY_SPEECH_RATE  0.1666
#define MY_SPEECH_MPX  1.55

    AVSpeechSynthesizer *textToSpeech = [[AVSpeechSynthesizer new]autorelease];
    NSString *language = [AVSpeechSynthesisVoice currentLanguageCode];
    if (language==nil) language = @"en-us";
    AVSpeechUtterance *speak = [AVSpeechUtterance speechUtteranceWithString:text];
    [speak setRate:MY_SPEECH_RATE];
    [speak setPitchMultiplier:MY_SPEECH_MPX];
    [speak setVoice:[AVSpeechSynthesisVoice voiceWithLanguage:language]];
    [textToSpeech speakUtterance:speak];
}

As you can see, I'm not using ARC but I don't think that makes the difference. (Also posted in the Developer's Forum)

like image 24
fundtimer Avatar answered Oct 28 '22 13:10

fundtimer