I use System.Speech library to able to recognize speech but it usually recognizes very different.
SpeechRecognizer_rec = new SpeechRecognizer();
DictationGrammar grammar = new DictationGrammar();
grammar.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(grammar_SpeechRecognized);
_rec.LoadGrammar(grammar);
How can I improve the recgonition? Does it have a relation with Grammer class?
If you can afford to ask users go to the training process that will certainly yield you much better results. I have used for myself (and I have an accent) and it improved significantly the accuracy of the recognition in my applications.
At the very least you can try it yourself (Control Panel, Speech Recognition, Train your computer to better understand you). Really, training or reducing the model (or of course using your app in a quiet place with a better microphone) are the only ways to improve the accuracy of your results.
You have to limit the model (basically the mapping from speech input to allowed English text output) used by the speech recognition engine to get high confidence output. The smaller your model is, the better your results will be in general, since there is less chance for the recognizer picking i.e. the wrong word between two similar sounding words.
This simplified example i.e. would only be able to recognize the numbers from one to three:
SpeechRecognizer rec = new SpeechRecognizer();
Choices c = new Choices();
c.Add("one");
c.Add("two");
c.Add("three");
var gb = new GrammarBuilder(c);
var g = new Grammar(gb);
rec.LoadGrammar(g);
The DictationGrammar yields somehow weird results, I tried out different properties of the SpeechRecognitionEngine, barely successful.
Try out:
SpeechRecognitionEngine.BabbleTimeOut
But read about usage first to prevent Errors.