我正在尝试突出显示文本到语音中读取的单词,但它不起作用。直到现在我做了:
string startSpan = "<span style=" + "background-color:Yellow" + ">";
string endSpan = "</span>";
//button onclick
protected void speak_Hope(object sender, EventArgs e)
{
speaker.Rate = -4;
speaker.SpeakAsync(announce.InnerText);
speaker.SpeakProgress += new EventHandler<SpeakProgressEventArgs> (speaker_SpeakProgress);
System.Diagnostics.Debug.WriteLine("processing");
}
void speaker_SpeakProgress(object sender, SpeakProgressEventArgs e)
{
counter2 = e.CharacterPosition - 10;
counter3 = e.Text.Length;
counter4 = counter2 + counter3;
System.Diagnostics.Debug.WriteLine(e.CharacterPosition - 10 + " next one" + e.Text);
announce.InnerHtml = announce.InnerText.Substring(0, counter2) + startSpan + announce.InnerText.Substring(counter2, counter3) + endSpan + announce.InnerText.Substring( announce.InnerText.Length - 1);
}
我做得对还是有其他方法,可以用javascript方式完成吗?多谢