AVSpeechSynthesizer error AudioSession

后端 未结 4 455
轻奢々
轻奢々 2021-02-05 08:31

I\'m playing around with AVSpeechSynthesizer and always getting these errors:

ERROR:     >aqsrv> 65: Exception caught in (null) - error -66634
ERROR:     A         


        
相关标签:
4条回答
  • 2021-02-05 08:36

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

    0 讨论(0)
  • 2021-02-05 08:37

    I can't believe it, but I actually found the solution for this: if you have no headphones plugged or any audio output source, AVPlayer won't work and it'll print:

    ERROR:     >aqsrv> 65: Exception caught in (null) - error -66634
    
    0 讨论(0)
  • 2021-02-05 08:46

    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)

    0 讨论(0)
  • 2021-02-05 08:53

    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

    0 讨论(0)
提交回复
热议问题