iPhone - 关于处理时间的问题
我正在开发一些应用程序,它也有语音叙述的文本,运行良好。 (文本和音频均为静态文件) 我想根据音频突出显示该单词。 我也可以编写代码来突出显示单词。
我已经确定了单词的开始和结束持续时间。就像如果文本是“Hi How are you”,从音频持续时间来看,Hi - 开始是 0.132,结束是 2.43,How - 开始是 3.45,结束是 4.72,are - 开始是 5.29,结束是 6.05 等等..
所以,我要做的就是在音频开始后 0.132 秒处突出显示“Hi”一词,并在 2.43 秒处使其正常。
我不知道如何实现 NSTimer 来处理这种情况。我的想法是正确的还是我必须遵循其他代码?
有人可以指导我如何实现这一点吗?
I'm working on some app which has text narrated by speech as well which is working fine.
(Text and audio are static files)
I want to high light the word according to audio.
I'm able to write the code to highlight word as well.
I've starting and ending duration of the words. Like if the text is "Hi How are you", From the audio duration, for Hi - start is 0.132 and end is 2.43, How - start is 3.45 and end is 4.72, are - start is 5.29 and end is 6.05 and so on..
So, what I've to do is highlight the word "Hi" at 0.132 seconds after the start of audio and make it normal at 2.43 seconds.
I don't know how can I implement NSTimer to handle this situation. Is my thinking correct or I've to follow some other code?
Can some one guide me on how to do implement this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这取决于您想要突出显示时间的准确性。 Apple 在其定时器编程主题中指出,定时器时间间隔的有效分辨率限制在 50-100 毫秒左右。
所以我能想到的是,如果准确性足以满足您的情况,您可以启动突出显示,重新启动计时器,在 x 秒后设置触发事件,当它触发时,关闭突出显示并转到下一个单词。
It depends on how much accuracy you want to time your highlighting. Apple state in its Timer Programming Topics, the effective resolution of the time interval for a timer is limited to on the order of 50-100 milliseconds.
So what I can think of, if the accuracy is enough for your case, you can start the highlight, restart timer, setup a firing event after x seconds, when it fires, turn of the highlighting and go to the next word.