问题描述
我正在为ipad开发一个应用程序,我想在其中添加如下功能: -
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.
我知道iOS的内置功能,但我想以编程方式进行。
I know about in built feature of iOS but i want to do it programatically.
我搜索了很多,得到如下:
I searched a lot and got as below:
如果有人知道任何API或任何内置框架。让我知道。
If anyone know any API or any inbuilt framework. Let me know.
感谢您的时间。
推荐答案
您可以使用精彩的文本到语音库,内置iOS 7以及AVSpeechSynthesizer。
You can make use of the brilliant text-to-speech library inbuilt with iOS 7 onwards called AVSpeechSynthesizer.
您可以使用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.
查看以及 API参考。
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.
这篇关于正在运行“文本到语音”时突出显示文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!