简体   繁体   English

在阅读(SpeechSynthesizer)Textbox / RichtextBox中的特定单词时,如何突出显示文本?

[英]How to highlight a text while reading (SpeechSynthesizer) a specific word in Textbox/RichtextBox?

SpeechSynthesizer reader = new SpeechSynthesizer(); SpeechSynthesizer reader =新的SpeechSynthesizer();

reader.SpeakAsync(richTextBox1.SelectedText); reader.SpeakAsync(richTextBox1.SelectedText);

// highlight a text while reading (SpeechSynthesizer) a specific word in richTextBox1. //在阅读(SpeechSynthesizer)richTextBox1中的特定单词时突出显示文本。

The SpeechSynthesizer raises different Events while progressing. SpeechSynthesizer在进行过程中引发不同的事件。

The one for words is SpeechSynthesizer.SpeakProgress . 一个词是SpeechSynthesizer.SpeakProgress Hook up an eventlistener and Color the text in your TextBox inside of that. 连接一个事件监听器,并在其中的文本框中为文本上色。

You should use SpeakProgress event which raises for each new word was pronounced 您应该使用SpeakProgress事件,该事件会为每个新单词发音发出

The SpeechSynthesizer raises this event for each new word that it speaks in a prompt using any of the Speak, SpeakAsync, SpeakSsml, or SpeakSsmlAsync methods. SpeechSynthesizer使用Speak,SpeakAsync,SpeakSsml或SpeakSsmlAsync方法中的任何一个,针对在提示中说出的每个新单词引发此事件。 For an example and more information about data associated with the event, see SpeakProgressEventArgs. 有关示例和与事件关联的数据的更多信息,请参见SpeakProgressEventArgs。 MSDN MSDN

There is also a good example from Microsoft hot to use this event to check what text pronounced: MSDN 还有一个很好的例子,来自Microsoft的热门使用此事件来检查发音的文本: MSDN

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM