Question

I'm currently developing an application of Speech Recognition using Microsoft Kinect SDK. The goal of the application is to load any (valid) XML file containing the grammar and use it to process speech.

The application is based on a already existing one and I pretty much understand all of its code except for one part:

            RecognizerInfo ri = GetKinectRecognizer();
        if (ri != null)
        {
            this.spRecEng = new SpeechRecognitionEngine(ri.Id);
            using (var memoryStream = new MemoryStream(Encoding.ASCII.GetBytes(Properties.Resources.SpeechGrammar)))
            {
                var g = new Grammar(memoryStream);
                spRecEng.LoadGrammar(g);
            }
            spRecEng.SpeechRecognized += spRecEng_SpeechRecognized;
            spRecEng.SpeechRecognitionRejected += spRecEng_SpeechRecognitionRejected;

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

Regarding the "Properties.Resources.SpeechGrammar" referencem when I closely inspect the content the application properties, it has, among other things, the following function:

  internal static string SpeechGrammar {
        get {
            return ResourceManager.GetString("SpeechGrammar", resourceCulture);
        }

What is the purpose behind this function? The application didn't include a Schema file used to validate the XML grammar files that the application loads so where is it getting it from?

I'm also including the source code of the project (it is really small), you can find it at: https://dl.dropboxusercontent.com/u/28555145/KinectForWindowsSpeech.rar

Was it helpful?

Solution

The project includes an XML file with the grammar for speech recognition. This kind of resources can be accessed through an ID assigned in project, it isn't needed to use the usual functions for tasks with files. Regarding validation, the project uses Microsoft.Speech libraries which do the validation, for example, you will get an exception in grammar load if the xml file does not contain a root element.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top