AVSpeechSynthesizer error AudioSession

后端 未结 4 468
轻奢々
轻奢々 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 with this SpeechSynthesis code, things seemed to speed up quite a bit when using the new @import AVFoundation;.

提交回复
热议问题