Ios AVSpeechSynthesizer错误音频会话

Ios AVSpeechSynthesizer错误音频会话,ios,objective-c,avfoundation,avaudiosession,Ios,Objective C,Avfoundation,Avaudiosession,我在玩AVSpeechSynthesizer,总是会遇到以下错误: ERROR: >aqsrv> 65: Exception caught in (null) - error -66634 ERROR: AVAudioSessionUtilities.h:88: GetProperty_DefaultToZero: AudioSessionGetProperty ('disa') failed with error: '?ytp' 我的代码是: AVSpeechSy

我在玩AVSpeechSynthesizer,总是会遇到以下错误:

ERROR:     >aqsrv> 65: Exception caught in (null) - error -66634
ERROR:     AVAudioSessionUtilities.h:88: GetProperty_DefaultToZero: AudioSessionGetProperty ('disa') failed with error: '?ytp'
我的代码是:

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

有人知道如何修复这些错误吗?

我得到了上面的代码,只需稍加调整即可在模拟器上工作

  • 代码的
    [[self text]text]
    位可能是错误的(这就是
    异常捕获(null)
    错误的原因)。下面的代码对我有用

    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];
    
    当我说“工作”时,我的意思是我听到有声音在我的模拟器里说出我的测试句子

    我仍然看到这个警告:

    2013-09-21 11:37:56.454语音[5550:3a03]11:37:56.454错误:AVAudioSessionUtilities.h:88:GetProperty_DefaultToZero:AudioSessionGetProperty(“disa”)失败,错误为“?ytp”


  • Xcode 5在尝试使用传统的
    #import
    时速度似乎很慢。使用此SpeechSynthesis代码,使用新的
    @import AVFoundation时,速度似乎加快了不少


  • 我在模拟器中得到了完全相同的错误日志,但我对模拟器或iPhone 5设备上的代码没有问题,正如您在别处指出的那样。区别可能是我没有使用这6个可选的avspeechsyzizerdelegates中的任何一个,因此,我没有将它包括在我的类协议中。因此,为了帮助跟踪您的错误,您可以不必担心就尝试它。这是我的测试代码,逻辑上与您的相同,减去委托和任何AVSpeechOuttence存储分配:

    -(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];
    }
    
    正如你所看到的,我没有使用弧,但我不认为这有什么区别。(也发布在开发者论坛上)

    我也看到了这些错误(使用ARC而不是多线程),但仅在模拟器上,而不是在真正的设备上

    我的工作假设他们是一个模拟器的限制,可以安全地忽略-其他一切似乎工作良好


    阿里

    我不敢相信,但我确实找到了解决办法:如果你没有插上耳机或任何音频输出源,AVPlayer将无法工作,它将打印:

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

    我只在iOS模拟器中看到了这一点,而不是在设备上。你看到的是相同的吗?我也很好奇这是否只是一个模拟器的例外。我在模拟器中使用AVFoundation时遇到了其他异常。哦,是的,对了,这里也一样!我也有同样的问题-我刚刚更新到Xcode 5.0.2,没有修复。当我打开所有异常(我必须切换到所有objective-c异常)时,它也抛出了一个异常。在使用Xcode 5.0.2的模拟器上,我遇到了相同的错误。我在运输代码中使用了它,没有收到任何投诉,iTunesConnect中也没有出现任何崩溃。我的声音已经正常了。我只是想知道为什么会出现这些错误。
    @import-AVFoundation
    对您有用吗?在“
    @import-AVFoundation;
    ”之后添加一个分号,您应该就没事了。不幸的是,我仍然得到
    错误:AVAudioSessionUtilities.h:88:GetProperty\u DefaultToZero:AudioSessionGetProperty('disa')失败,错误为:“?ytp”
    @import-AVFoundation?你是怎么编译的?我的控制台里也有那个“错误”@h345k34cr;而@Josh我在Xcode5中使用了“
    @import AVFoundation;
    ”。这是最近推出的一种全新产品。我的代码也很好用。但是这些错误日志很烦人,它让我觉得有些地方不对劲。