title: Dictation grammar vs custom grammar
body: <p>I am working on the following code</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Speech.Recognition;
  using System.Speech.Synthesis;
  using System.Windows.Forms;
  using System.IO;
  
  namespace US_Speech_Recognizer
  {
      public class RecognizeSpeech
      {
          private SpeechRecognitionEngine sEngine; //Speech recognition engine
          private SpeechSynthesizer sSpeak; //Speech synthesizer
          string text3 = "";
  
          public RecognizeSpeech()
          {
              //Make the recognizer ready
              sEngine = new SpeechRecognitionEngine(new System.Globalization.CultureInfo("en-US"));
  
  
              //Load grammar
              Choices sentences = new Choices();
              sentences.Add(new string[] { "I am hungry" });
  
              GrammarBuilder gBuilder = new GrammarBuilder(sentences);
  
              Grammar g = new Grammar(gBuilder);
  
              sEngine.LoadGrammar(g);
  
              //Add a handler
              sEngine.SpeechRecognized +=new EventHandler&lt;SpeechRecognizedEventArgs&gt;(sEngine_SpeechRecognized);
  
  
              sSpeak = new SpeechSynthesizer();
              sSpeak.Rate = -2;
  
  
  
              //Computer speaks the words to get the phones
              Stream stream = new MemoryStream();
              sSpeak.SetOutputToWaveStream(stream);
  
  
              sSpeak.Speak("I was hungry");
              stream.Position = 0;
              sSpeak.SetOutputToNull();
  
  
              //Configure the recognizer to stream
              sEngine.SetInputToWaveStream(stream);
  
              sEngine.RecognizeAsync(RecognizeMode.Single);
  
  
          }
  
  
          //Start the speech recognition task
          private void sEngine_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
          {
              string text = "";
  
              if (e.Result.Text == "I am hungry")
              {
                  foreach (RecognizedWordUnit wordUnit in e.Result.Words)
                  {
                      text = text + wordUnit.Pronunciation + "\n";
                  }
  
                  MessageBox.Show(e.Result.Text + "\n" + text);
              }
  
  
          }
      }
  }
  </code></pre>
  
  <p>In here, the grammar is <code>I am hungry</code> but the computer is asked to speak <code>I was hungry</code>. But the case is, the recognition event get fired and says the text is exact equal to <code>I am hungry</code>. In the output box, you can check the phonemes as well!</p>
  
  <p>The only way to avoid this is loading <code>DictationGrammar</code></p>
  
  <p>I thought providing custom grammar is the best way to restrict the application from listening to everything not needed, but it seems like custom grammar is failing! </p>
  
  <p>My question is, is there a way to avoid this? Why this is happening? </p>