C# system.speech.recognition alternate words

后端 未结 1 1895
情书的邮戳
情书的邮戳 2021-01-25 01:17

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

相关标签:
1条回答
  • 2021-01-25 01:38

    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.

    0 讨论(0)
提交回复
热议问题