gpt4 book ai didi

ios - AVSpeechSynthesizer 错误 AudioSession

转载 作者:IT王子 更新时间:2023-10-29 08:09:21 24 4
gpt4 key购买 nike

我在玩 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];

有谁知道如何解决这些错误?

最佳答案

我得到了上面的代码,只需进行最少的调整就可以在模拟器上运行。

  1. [[self text] text]您的部分代码可能有误(这就是 Exception caught in (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 Speech[5550:3a03] 11:37:56.454 ERROR: AVAudioSessionUtilities.h:88: GetProperty_DefaultToZero: AudioSessionGetProperty ('disa') failed with error: '?ytp'

  2. Xcode 5 在尝试使用传统的 #import <AVFoundation/AVFoundation.h> 时似乎很慢使用此 SpeechSynthesis 代码,使用新的 @import AVFoundation; 时,事情似乎加快了很多.

关于ios - AVSpeechSynthesizer 错误 AudioSession,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18935875/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com