Reputation: 303
I have NSArray with words in it. I want to app reads that tts sequentially and print the text in UILabel what app speak. but word on label is shown the last one.
I tried time pause, etc
for (Word * w in ttswords) {
[self speechword:w];
}
-(void)speechword:(Word*)w{
utterance = [[AVSpeechUtterance alloc] initWithString:[w.title stringByReplacingOccurrencesOfString:@"~" withString:@""]];
utterance.voice = [AVSpeechSynthesisVoice voiceWithLanguage:@"en-US"];
[synthesizer speakUtterance:utterance];
_lb_title.text = w.title;
}
I want to execute one by one.
Upvotes: 1
Views: 64
Reputation: 5671
The best way to highlight the vocalized word is using the speechSynthesizer:willSpeakRangeOfSpeechString:utterance:
method of the AVSpeechSynthesizerDelegate
protocol.
If you don't use this delegate method, you won't be able to reach your goal.
Take a look at this complete and useful example (ObjC and Swift) that displays each vocalized word in a bold font with the speech synthesis.
Upvotes: 2