user1638121
user1638121

Reputation: 167

Kinect Speech Recognition

Modeled on the example from Kinect SDK

private static RecognizerInfo GetKinectRecognizer()
    {
        foreach (RecognizerInfo recognizer in SpeechRecognitionEngine.InstalledRecognizers())
        {
            string value;
            recognizer.AdditionalInfo.TryGetValue("Kinect", out value);
            if ("True".Equals(value, StringComparison.OrdinalIgnoreCase) && "en-US".Equals(recognizer.Culture.Name, StringComparison.OrdinalIgnoreCase))
            {
                return recognizer;
            }
        }

        return null;
    }

On Window Load

RecognizerInfo ri = GetKinectRecognizer();

        if (null != ri)
        {

            this.speechEngine = new SpeechRecognitionEngine(ri.Id);

             var directions = new Choices();
             directions.Add(new SemanticResultValue("forward", "FORWARD"));
             directions.Add(new SemanticResultValue("backward", "BACKWARD"));
             directions.Add(new SemanticResultValue("turn left", "LEFT"));
             directions.Add(new SemanticResultValue("turn right", "RIGHT"));

             var gb = new GrammarBuilder { Culture = ri.Culture };
             gb.Append(directions);

             var g = new Grammar(gb);

            speechEngine.SpeechRecognized += SpeechRecognized;
            speechEngine.SpeechRecognitionRejected += SpeechRejected;

            speechEngine.SetInputToAudioStream(
            kinect.AudioSource.Start(), new SpeechAudioFormatInfo(EncodingFormat.Pcm, 16000, 16, 1, 32000, 2, null));
            speechEngine.RecognizeAsync(RecognizeMode.Multiple);
        }

Error:

An unhandled exception of type 'System.InvalidOperationException' occurred in Microsoft.Speech.dll

Additional information: At least one grammar must be loaded before doing a recognition.

What i can to do?

Upvotes: 1

Views: 876

Answers (1)

carolina
carolina

Reputation: 98

i have had the same error. The ri is null, there are not Language packs installed in your computer. And even if you have installed them, it could not find them. What you have to do is uninstall EVERYTHING, kinect sdk, driver, runtime, toolkit, microsoft speech x64/x86 and language packs. Then install everything again in this order:

1ST: KINECT SDK (it comes with all the rest u need like driver) 2nd: Microsoft Speech 3rd: language packs

I am using kinect sdk 1.5 i had this very same problem for 4 days until somebody from microsoft told me that this could be a possible solution and it was.

Regards! Carolina

Upvotes: 1

Related Questions