Posts

Post not yet marked as solved
0 Replies
247 Views
Here is my problem , I can't understand why AVSpeechSynthesizer pause no effect.I have a AVSpeechSynthesizer object, and this object have 5 uttrances in its queue.so , i do like this:when the first uttrance in the queue play finished, i call AVSpeechSynthesizer pauseSpeakingAtBoundary method immediately, but there is no effect , the second uttrance still will be played.my code like this:- (void)beginConversation { for (NSInteger i = 0; i < [_speechStrings count]; i++) { AVSpeechUtterance *uttrance = [AVSpeechUtterance speechUtteranceWithString:[_speechStrings objectAtIndex:i]]; uttrance.voice = [_voices firstObject]; uttrance.rate = AVSpeechUtteranceMaximumSpeechRate * 0.5; uttrance.pitchMultiplier = 1.0f; [_synthesizer speakUtterance:uttrance]; } } // button Click to pause or resume AVSpeechSynthesizer - (void)pauseOrPlaySpeech { AVSpeechSynthesizer *synthesizer = _speech.synthesizer; if ([synthesizer isPaused]) { if (![synthesizer continueSpeaking]) { NSLog(@"continue speaking error"); } } else { if ([synthesizer isSpeaking]) { if (![synthesizer pauseSpeakingAtBoundary:AVSpeechBoundaryWord]) { NSLog(@"pause speaking error"); } } else { [_speech beginConversation]; } } }
Posted Last updated
.