C# system.speech.recognition alternate words

感情迁移 提交于 2019-12-02 06:17:30

This MSDN page handles what you're asking quite nicely. For reference, I'll post the included code. The final for loop is what contains the

// Handle the SpeechRecognized event. 
void SpeechRecognizedHandler(object sender, SpeechRecognizedEventArgs e)
{
  //... Code handling the result

  // Display the recognition alternates for the result.
  foreach (RecognizedPhrase phrase in e.Result.Alternates)
  {
    Console.WriteLine(" alt({0}) {1}", phrase.Confidence, phrase.Text);
  }
}

The use of e.Result.Alternates is the official way to obtain other possible words.

If that isn't giving you enough results, this MSDN page gives you the required information. You need to use UpdateRecognizerSetting on your SpeechRecognitionEngine to change the confidence rejection level. Setting it to 0 will make every single result display in Alternates along with the confidence levels, which you can sort to obtain the top 10.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!