Question

I am using microsoft.speech to recognize the speech out of a wave file in my machine.

Instead of adding words to choice set, I am reading the words from a text file and then adding the words to the grammar.

But I found out that when I try to add more than 73 words to the grammar, that my recorded file never gets recognized.

Here is my code:

System.IO.StreamReader file = new System.IO.StreamReader(filePath);
                while ((line = file.ReadLine()) != null)
                {
                    if (line != "")
                    {
                        words.Add(line);
                        counter++;
                    }
                }

                file.Close(); 


                gb.Append(words);

                // Create the actual Grammar instance, with the words from the source audio.
                g = new Grammar(gb);

                // Load the created grammar onto the speech recognition engine.
                recognitionEngine.LoadGrammarAsync(g);



 public void recognizer_SpeechRecognizedRecording(object sender, SpeechRecognizedEventArgs e)
        {
            string text = e.Result.Text;
}

But when more than 73 words are present in my text file, I am not getting any hit in the speech recognizer recording event.

Please can somebody help me to achieve this?

Was it helpful?

Solution

You can try ordering your phrases a bit and using the Append(String, SubsetMatchingMode) method; in particular, the OrderedSubset will allow matching any linear subset of the string.

More likely, however, is that 10,000 words are simply too much data for a command & control grammar. A better option is to use a DictationGrammar, not a command & control grammar. Add the words to a lexicon to be sure the dictation engine will be able to recognize the words, and then match the recognitions against your wordlist.

Upon reviewing your question, though, it seems as if you're using the Microsoft.Speech namespace, which uses the Server engine that does not support dictation; your only option then is the first one.

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