-1

在应用程序说完之前,我需要禁用与用户的交互。请参见下面的示例代码:

self.view.userInteractionEnabled = NO;
[self speak :@"wait for me to speak"];
self.view.userInteractionEnabled = YES;

-(void)speak:(NSString*)word
{
    AVSpeechUtterance *utterance = [[AVSpeechUtterance alloc] initWithString:word];
    utterance.rate = AVSpeechUtteranceMinimumSpeechRate;
    utterance.rate = 0.2f;
    utterance.voice = [AVSpeechSynthesisVoice voiceWithLanguage
    [AVSpeechSynthesisVoice currentLanguageCode]];
    [synthesizer speakUtterance:utterance];
}
4

1 回答 1

1

使用委托(AVSpeechSynthesizerDelegate)。它会告诉您演讲何时结束,因此现在再次启用用户交互。

于 2015-02-05T04:22:54.773 回答