我正在尝试构建一个显示消息框的应用程序,该消息框在说出音素的确切时刻显示音素。问题是这些消息框在演讲结束后等待显示音素。我怎样才能同时做这两件事?
void sre_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
{
speech = new SpeechSynthesizer();
speech.SetOutputToDefaultAudioDevice();
speech.SpeakAsync(e.Result.Text);
speech.PhonemeReached += speech_PhonemeReached;
}
void speech_PhonemeReached(object sender, PhonemeReachedEventArgs e)
{
if (new[] {"a͡i","o"}.Contains(e.Phoneme))
MessageBox.Show(e.Phoneme);
}
我还在学习 c#,我不太确定如何使用线程,但这是我与语音识别器相关的代码部分:
Thread q = new Thread( ()=> sre.SpeechRecognized += (s, args) =>
{
foreach (RecognizedPhrase phrase in args.Result.Alternates)
{
if (phrase.Confidence > 0.9f)
sre_SpeechRecognized(s, args);
}
});
q.Start();
希望任何人都可以帮助我...