我在尝试使用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];有人知道如何修复这些错误吗?
发布于 2013-09-22 02:40:45
我得到了上面的代码,以便在模拟器上进行最小的调整。
[[self text] text]位可能是错误的(这就是Exception caught in (null)错误的来源)。下面的代码对我很有效。AVSpeechSynthesizer *synthesizer = [AVSpeechSynthesizer alloc ];合成器setDelegate:self;//设置您的类符合AVSpeechSynthesizerDelegate协议float speechSpeed = AVSpeechUtteranceMinimumSpeechRate;AVSpeechUtterance *synUtt = [AVSpeechUtterance alloc:@“hello I I am testing"];synUtt setRate:speechSpeed;[synUtt setVoice:[AVSpeechSynthesisVoice voiceWithLanguage:AVSpeechSynthesisVoice currentLanguageCode]];合成器扬声器setDelegate:synUtt;
当我说“有效”时,我的意思是我在模拟器中听到了我的测试句子的声音。我仍然看到了这个警告:
2013-09-21 11:37:56.454 Speech5550:3a03 11:37:56.454错误: AVAudioSessionUtilities.h:88: GetProperty_DefaultToZero: AudioSessionGetProperty ('disa')失败,错误为:'?ytp'
#import <AVFoundation/AVFoundation.h>时似乎有一段很慢的时间,在使用新的SpeechSynthesis代码时,速度似乎快了不少发布于 2013-10-27 17:41:14
我也看到了这些错误(使用ARC,但不是多线程),但只在模拟器上,而不是在真实的设备上。
我的工作假设它们是模拟器的限制,可以安全地忽略--其他一切似乎都运行得很好。
阿里
发布于 2013-10-04 10:41:00
我在模拟器中得到了完全相同的错误日志,但无论是模拟器中的代码还是iPhone 5设备上的代码都没有问题,正如您在其他地方指出的那样。不同之处可能是我没有使用这6个可选AVSpeechSythesizerDelegates中的任何一个,因此,我没有在我的类协议中包含它。因此,为了帮助跟踪您的错误,您可以尝试不使用它。以下是我的测试代码,逻辑上与您的相同,只是去掉了委托和任何AVSpeechUtterance存储分配:
-(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,但我不认为这有什么不同。(也发表在开发者论坛上)
https://stackoverflow.com/questions/18935875
复制相似问题