I want to track the number of utterances in queue for AVSpeechUtterance. So I have multiple strings that are going to be spoken in the order that I set them up to speak. Is there a way I can track which utterance number is being spoken?
So say I have 10 utterances in queue to be spoken. I want to be able to NSLog which one is being spoken. So it should NSLog the following: Utterance 6 Being Spoken
. Is there a way I can do this?
You can use AVSpeechSynthesizerDelegate
and its speechSynthesizer:didStartSpeechUtterance:
method. Let's assume that you store AVSpeechUtterance
objects in a NSArray
named utterances
:
- (void)speechSynthesizer:(AVSpeechSynthesizer *)synthesizer didStartSpeechUtterance:(AVSpeechUtterance *)utterance {
NSUInteger utternanceNo = utterances indexOfObject:utterance];
NSLog(@"Utterance %@ being spoken", @(utteranceNo));
}