编辑:下面关于重新创建合成器的评论似乎仅与 iOS8.0.0 和 GM 相关 - 在 iOS8.0.2 中似乎没有必要,user848555 的解决方法现在对我来说很好。有趣的是,user848555 的解决方法似乎仍然是必要的(至少如果您更改语言),尽管我在其他线程上看到它已在 iOS8.0.2 中修复的评论。
所以这似乎是与低质量语音相关的错误 - 它在此处的发行说明中被引用(在此页面上搜索语音合成):
[ https://developer.apple.com/library/ios/releasenotes/General/RN-iOSSDK-8.0/][1]
Apple 的官方解决方法是为不工作的声音下载高质量的声音(默认情况下,一个声音始终是高质量的 - 英语国家的美国英语,可能在其他国家会发生变化),这就是为什么它似乎工作的原因你坚持默认的声音。
如果(像我一样)你不断地改变声音,user848555 的解决方法不能孤立地工作。但是,如果您在每个似乎有效的话语上重新创建 SpeechSynthesizer。这是我的代码(它特定于我的应用程序,因此您需要更改一些内容,但它应该说明这一点)。它使用 user848555 对空白话语的修复以及对每个话语的重新创建。
-(void)speakGerman:(NSString*)text{
if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_6_1 ||
[self.dataController.speakSetting integerValue] == 2) return;
// iOS8 fix
speechSynthesizer = [[AVSpeechSynthesizer alloc]init];
AVSpeechUtterance *bugWorkaroundUtterance = [AVSpeechUtterance speechUtteranceWithString:@" "];
bugWorkaroundUtterance.rate = AVSpeechUtteranceMaximumSpeechRate;
[speechSynthesizer speakUtterance:bugWorkaroundUtterance];
AVSpeechUtterance *utterance;
utterance = [AVSpeechUtterance speechUtteranceWithString:text];
utterance.voice = germanVoice;
utterance.rate = 0.2;
utterance.preUtteranceDelay = 0.0;
[speechSynthesizer speakUtterance:utterance];
}
阿里[1]:https ://developer.apple.com/library/ios/releasenotes/General/RN-iOSSDK-8.0/