AVSpeechSynthesizer与ios8

Gre*_*eye 5 objective-c ios avspeechsynthesizer

HI有没有人在iOS 8上试过AvSpeechSynthesizer?我在Xcode 6上做了快速的应用程序,但没有音频出来,我在Xcode 5上运行同样的工作并且没有任何障碍.

示例代码来自http://nshipster.com/avspeechsynthesizer/

NSString *string = @"Hello, World!";
AVSpeechUtterance *utterance = [[AVSpeechUtterance alloc] initWithString:string];
utterance.voice = [AVSpeechSynthesisVoice voiceWithLanguage:@"en-US"];

AVSpeechSynthesizer *speechSynthesizer = [[AVSpeechSynthesizer alloc] init];
[speechSynthesizer speakUtterance:utterance];
Run Code Online (Sandbox Code Playgroud)

Xcode6的错误?

==编辑===看起来像iOS 8 sim的bug /问题,iOS7.1 Sim与Xcode6工作正常..

use*_*555 9

是的,这是一个错误.从iOS8 GM开始,似乎首次尝试让AVSpeechSynthesizer说AVSpeechUtterance会导致沉默.

我的解决方法是让AVSpeechSynthesizer在初始化后立即说出一个单字符的话语.这将是沉默的,之后您的AVSpeechSynthesizer将正常工作.

AVSpeechUtterance *bugWorkaroundUtterance = [AVSpeechUtterance speechUtteranceWithString:@" "];
bugWorkaroundUtterance.rate = AVSpeechUtteranceMaximumSpeechRate;
[self.speechSynthesizer speakUtterance:bugWorkaroundUtterance];
Run Code Online (Sandbox Code Playgroud)