Highlight text while Text to Speech is running

戏子无情 提交于 2019-11-30 15:54:36

问题


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

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.


回答1:


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.



来源:https://stackoverflow.com/questions/26624494/highlight-text-while-text-to-speech-is-running

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!