C# system.speech.recognition alternate words

前提是你 提交于 2019-12-20 04:18:50

问题


I am currently using the Microsoft.Speech API to dictate utterances into text, but what I really need is the alternative dictations the program could use. I am using this for my honours thesis, and for it I wish to know the top 10 interpretations of any utterance.

A very similar, if not exact question was asked in 2011: C# system.speech.recognition alternates

But was never answered. My question thus is: how does one get the alternatives to an interpretation of a dictation using the Microsoft.Speech API?


回答1:


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.



来源:https://stackoverflow.com/questions/17247473/c-sharp-system-speech-recognition-alternate-words

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