Get the list of recognized words from Kinect speech commands

By | January 20, 2014

When a speech is recognized by the Speech Recognizer engine, the Speech Recognizer returns the recognized words as collection of the type RecognizedWordUnit class.  This set of words are extremely useful to deal with any sentences. In my previous post, I discussed about recognizing a statement like “draw a read circle” or “draw a green circle”; where we had to identify the sentences from the Kinect captured audio and then splitting it in a series of words.
With Microsoft Speech API, the SpeechRecognitionEngine class handles all the operation related with the speech. You can then attach an event handler to the SpeechRecognized event, which will fire whenever the audio is internally converted into text and identified by the recognizer. The following code shows how you can create an instance of SpeechRecognitionEngine and register the Speech Recognized event handler.

SpeechRecognitionEngine speechRecognizer = new SpeechRecognitionEngine();
speechRecognizer.SpeechRecognized += speechRecognizer_SpeechRecognized;

Once the speech is recognized, you can perform the required operation using the SpeechRecognizedEventArgs.Result property as follows:

void speechRecognizer_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
{
Console.WriteLine("Recognized Text {0} ", e.Result.Text);
}

The SpeechRecognizer event handler has a Result property of type RecognitionResult class. The Result property contains what has been identified and the quality in terms of confidence level.
So if you speak “draw a green cirecle” , the Text value of the Result will be the “Draw a green Circle” . Whereas the “Words”, class will contains the list of all identified words as a collection.
Words from Speech Command in Kinect
You write following code snippet to get the list of identified words

private void GetListOfWords(RecognitionResult result)
{
StringBuilder sb = new StringBuilder();
foreach (var word in result.Words)
{
Console.Write(word.Text);
}
}

Here is how you can get the list of words while debugging

List of Words

 

 

 

 

One thought on “Get the list of recognized words from Kinect speech commands

  1. Pingback: 14 Tips and Tricks on Kinect for Windows SDK | Abhijit's World of .NET

Comments are closed.