Skip to content

Windows 7 Desktop Speech Recognition C#

kotaiba watted

Asked Apr 5, 2010, 9:21 AM EDT1 answer
Share
LinkedInX

Hi please help me...

this is my code for  Speech Recognation it's work fine

but i have problem with the speech itself like when i say

"start menu" or something default for Speech Recognation it's open the start menu

and i don't want this in my program ,i need it only to recogize what i wrote to him in the code

just the grammar

 

C#
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Speech.Recognition;


namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        SpeechRecognizer speechReco = new SpeechRecognizer();


        List<string> grammerList = new List<string>();


        public Form1()
        {
            InitializeComponent();
            this.grammerList.Add("one");
            this.grammerList.Add("two");
            Choices myChoices = new Choices(grammerList.ToArray());


            GrammarBuilder builder = new GrammarBuilder(myChoices);


            Grammar gram = new Grammar(builder);


            speechReco.LoadGrammar(gram);
            gram.Enabled = true;


            speechReco.Enabled = true;


            speechReco.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(speechReco_SpeechRecognized);




        }
        void speechReco_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
        {
            String speech = e.Result.Text;
            lblSpeech.Text = speech;
        }
    }
}

 thanks

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    If you use SpeechRecognitionEngine instead of SpeechRecognizer it will only recognize things from your grammer. Everything is very similar except that you will need to change the
    speechReco.Enabled = true;
    to something more like this:
    speechReco.SetInputToDefaultAudioDevice();
    speechReco.RecognizeAsync(RecognizeMode.Multiple);
    0