Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Highlight text while Text to Speech is running

I am developing an app for ipad in which i want to add functionality as below:-

enter image description here

When user'll tap on play button Text to speech will start to play that Text at that time, that word will be highlighted as they are being read.

I know about in built feature of iOS but i want to do it programatically.

I searched a lot and got as below:

Link 1

Link 2

Link 3

If anyone know any API or any inbuilt framework. Let me know.

Appreciate your time.

like image 831
Er.Shreyansh Shah Avatar asked Oct 29 '14 07:10

Er.Shreyansh Shah


1 Answers

You can make use of the brilliant text-to-speech library inbuilt with iOS 7 onwards called AVSpeechSynthesizer.

You can control the speech as well as get notifications of it's progress using the AVSpeechSynthesizer delegate methods. The method that should help you achieve your desired functionality should be the speechSynthesizer:willSpeakRangeOfSpeechString:utterance: method.

Have a look at the AVSpeechSynthesizer as well as the AVSpeechSynthesizerDelegate API reference.

This post by Matt Thompson on NSHipster features the exact same functionality with an example.

like image 111
ZeMoon Avatar answered Sep 28 '22 04:09

ZeMoon