我正在尝试根据音频来弄清楚用哪种技术来启动文本。很像 https://spechify.com/
正在做什么。
这是假设我能够运行TTS算法,并且可以将文本转换为语音。
我尝试过多种资源,但我无法确定在音频说的时突出文本的确切技术或方法。
任何帮助都将不胜感激。我已经在互联网上浪费了2天来解决这个问题,但没有运气:(
I am trying to figure out which technology to use to hightlight a text as per the audio. Much like what https://speechify.com/
is doing.
This is assuming I am able to run a TTS algo and I am able to convert text to speech.
I have tried multiple sources but I am unable to pinpoint the exact technology or methodology of highlighting the text as the audio speaks.
Any help would be much appreciated. I have already wasted 2 days on the internet to figure this out but no luck :(
发布评论
评论(2)
一种简单的方法是使用用香草JS强调单词。发射的事件为我们提供了炭指数,因此无需使用Regexes或Super AI的东西疯狂:)
在其他任何事情之前,请确保API可用,
TTS话语发出了“边界”事件,我们可以使用它来突出显示文本。
完整示例:
codesandbox link
是非常基本的,您可以(并且应该)改进它。
编辑
oops,我忘记了这被标记为reactjs。这是与React相同的示例(CODESANDBOX链接在注释中):
A simple approach would be to use the event listener provided by the SpeechSynthesisUtterance boundary event to highlight words with vanilla JS. The emitted event gives us char indices, so no need to go crazy with regexes or super AI stuff :)
Before anything else, make sure the API is available
The tts utterance emits an 'boundary' event, we can use it to highlight text.
Full example:
CodeSandbox link
This is pretty basic, and you can (and should) improve it.
Edit
Ooops, I forgot that this was tagged as ReactJs. Here's the same example with React (codesandbox link is in the comments):
tts-react 提供了接受a
usetts
代码> MarkTextAssPoken 参数将突出显示所说的单词。这是一个例子:
您也可以从CDN加载它:
tts-react provides a hook
useTts
that accepts amarkTextAsSpoken
argument that will highlight the words being spoken.Here's an example:
You can load it from a CDN too: