I tried to implement text-to-speech search on my website.
What I tried to do this is to just highlight the text that what it speaking.
Here is my code
this.utterThis.onboundary=function(event){
if(event.name=='word'){
this.progress_index=event.charIndex;
console.log(textcontent.charAt(this.progress_index))
}
In console log, what it returns
is the index value of the first word.
It tells that all the p
tag text is in textcontent
variable.
var textcontent = (<HTMLIFrameElement>document.getElementById("description")).contentWindow.document.body.innerHTML;
So what I actually want is to highlight the text that it spoken using the index value.
Note: event.name returns word
.
Thank in advance.