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?
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