我创建了一个AVSpeechSynthesizer
并开始播放一个AVSpeechUtterance
. 这工作正常。如果用户按下按钮,我会暂停合成器。这也有效。但是,当我尝试使用该continueSpeaking
方法重新启动合成器时,没有任何反应。如果我检查该isSpeaking
属性,它仍然是NO
. 如何让音频从中断的地方重新开始播放?
AVSpeechSynthesizer *synthesizer_;
synthesizer_ = [[AVSpeechSynthesizer alloc] init];
synthesizer_.delegate = self;
- (void)textToSpeech{
AVSpeechUtterance *utterance = [[AVSpeechUtterance alloc]initWithString:itemText];
utterance.voice = [AVSpeechSynthesisVoice voiceWithLanguage:localeCode];
utterance.rate = UTTERANCE_RATE;
utterance.preUtteranceDelay = itemDelayTimeInterval;
[synthesizer_ speakUtterance:utterance];
}
- (IBAction)pauseButtonPressed:(id)sender {
if (synthesizer_.isSpeaking) {
[synthesizer_ pauseSpeakingAtBoundary:AVSpeechBoundaryWord];
}
else{
[synthesizer_ continueSpeaking];
}
}