Simulator
Simulator

Reputation: 166

AVSpeechSynthesizer get current position

I have a large block of text to be read by AVSpeechSynthesizer. Is it possible to get the current position of audio playing in AVSpeechSynthesizer and playback later from the same position even after user has terminated the application by storing the audio playback position?

Upvotes: 0

Views: 853

Answers (1)

flo
flo

Reputation: 685

You can have the AVSpeechSynthesizer notify you through the AVSpeechSynthesizerDelegate methods. From the documentation:

– speechSynthesizer:didCancelSpeechUtterance:
– speechSynthesizer:didContinueSpeechUtterance:
– speechSynthesizer:didFinishSpeechUtterance:
– speechSynthesizer:didPauseSpeechUtterance:
– speechSynthesizer:didStartSpeechUtterance:
– speechSynthesizer:willSpeakRangeOfSpeechString:utterance:

You could use the …willSpeakRange… to keep track of where you are in your text.
In this tutorial it is used to highlight the current word.

Upvotes: 0

Related Questions