Exemple #1
0
        private void SpeechStartup()
        {
            var CultureInfo = new System.Globalization.CultureInfo("en-US");

            speech = new SpeechRecognitionEngine(CultureInfo);

            Choices colors = new Choices();

            foreach (KnownColor item in colorsArray)
            {
                colors.Add(new string[] { item.ToString() });
            }


            speech.SetInputToDefaultAudioDevice();

            GrammarBuilder gb = new GrammarBuilder();

            gb.Append(colors);

            Grammar g = new Grammar(gb);

            speech.LoadGrammar(g);

            speech.SpeechRecognized +=
                new EventHandler <SpeechRecognizedEventArgs>(speech_SpeechRecognized);

            speech.SpeechRecognitionRejected += Speech_SpeechRecognitionRejected;

            speech.EmulateRecognize("Blue");

            speech.RecognizeAsync(RecognizeMode.Multiple);
        }