【发布时间】:2015-04-02 16:01:42
【问题描述】:
我在使用 AVSpeechSynthesizer 和话语时遇到问题 (ios 7.1.1)
AVSpeechSynthesizer 在处理程序类中初始化,委托为 self:
self.synthesizer = [[AVSpeechSynthesizer alloc] init];
self.synthesizer.delegate = self;
我在委托中实现了以下方法:
-(void)speechSynthesizer:(AVSpeechSynthesizer *)synthesizer didFinishSpeechUtterance:(AVSpeechUtterance *)utterance {
NSLog(@"Finish");
}
-(void)speechSynthesizer:(AVSpeechSynthesizer *)synthesizer didStartSpeechUtterance:(AVSpeechUtterance *)utterance{
NSLog(@"Start");
}
我的演讲是通过这种方法调用的:
- (void)speak:(NSString *)spokenWord{
AVSpeechUtterance *utterance = [[AVSpeechUtterance alloc] initWithString:spokenWord];
[self.synthesizer speakUtterance:utterance];
}
然后我重复调用该方法,例如
[AVhandler speak:_word];
[AVhandler speak:_word];
[AVhandler speak:_word];
我希望在日志中看到: 开始 结束 开始 结束 开始 完成等
但我看到的是: 开始 结束 结束 结束 完成
为什么没有调用 didStartSpeechUtterance?
谢谢。
【问题讨论】:
标签: ios7 delegates avspeechsynthesizer