none
Search List With SpeechRecognitionEngine RRS feed

  • Question

  • Hello,

      Does anyone know, is there a way with the SpeechRecognitionEngine to build a list of phrases with the GrammerBuilder and then allow the engine to sort of search the list to find it's closes phrase?  For example, I have 3 phrases:

    • The Dog Walks
    • The Dog Runs
    • The Dog Barks

    If the user speaks any of these phrases exactly the recognition engine correctly interprets the speech and displays a message box with the selected phrase.

    However, if the user just says:

    • "Dog Walks"
    • "Dog Runs"
    • "Runs"

    It won't be able to match any of those phrases. I don't however want to allow free form speech recognition where the user can say something outside of the list.  For example if the user says "Cat", then it shouldn't recognize anything.

    Here is my sample code, I'm not sure if anyone has any ideas?

    Thanks.

            private void button1_Click(object sender, EventArgs e)
            {
                SpeechRecognitionEngine mRecognizer = new SpeechRecognitionEngine();
                mRecognizer.SpeechRecognized += MRecognizer_SpeechRecognized;
                mRecognizer.LoadGrammar(new Grammar(new GrammarBuilder("The Dog Walks")));
                mRecognizer.LoadGrammar(new Grammar(new GrammarBuilder("The Dog Runs")));
                mRecognizer.LoadGrammar(new Grammar(new GrammarBuilder("The Dog Barks")));
                mRecognizer.SetInputToDefaultAudioDevice();
                mRecognizer.RecognizeAsync(RecognizeMode.Multiple);
            }
    
            private void MRecognizer_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
            {
                System.Windows.Forms.MessageBox.Show(e.Result.Text);
            }

    Monday, March 28, 2016 10:37 PM

Answers

  • Hi Ryanhav,

    >> is there a way with the SpeechRecognitionEngine to build a list of phrases with the GrammerBuilder and then allow the engine to sort of search the list to find it's closes phrase? 

    I haven't found any documents to verify that.

    But from my personal view, this is by design.

    For example, you can check Get Started with Speech Recognition in MSDN.

    The method builds a grammar incrementally using a Choices instance to add the strings "red", "green", and "blue".  It then creates a GrammarBuilder instance using the Choices object.

    From above picture, you can see the User use the exact word to match with grammar.

    Best regards,

    Kristin


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Proposed as answer by Ryan_Ha Tuesday, March 29, 2016 5:13 PM
    • Marked as answer by DotNet WangModerator Tuesday, April 5, 2016 6:37 AM
    Tuesday, March 29, 2016 9:37 AM

All replies

  • Hi Ryanhav,

    >> is there a way with the SpeechRecognitionEngine to build a list of phrases with the GrammerBuilder and then allow the engine to sort of search the list to find it's closes phrase? 

    I haven't found any documents to verify that.

    But from my personal view, this is by design.

    For example, you can check Get Started with Speech Recognition in MSDN.

    The method builds a grammar incrementally using a Choices instance to add the strings "red", "green", and "blue".  It then creates a GrammarBuilder instance using the Choices object.

    From above picture, you can see the User use the exact word to match with grammar.

    Best regards,

    Kristin


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Proposed as answer by Ryan_Ha Tuesday, March 29, 2016 5:13 PM
    • Marked as answer by DotNet WangModerator Tuesday, April 5, 2016 6:37 AM
    Tuesday, March 29, 2016 9:37 AM
  • Thank you Kristin, that seems to be working pretty well.

    Also - if anyone is interested the Project Oxford Speech API is incredibly accurate.  I unfortunately can't use it but sort of accomplishes a similar result as above.

    Tuesday, March 29, 2016 5:14 PM