当前位置: 首页>>代码示例>>C#>>正文


C# SpeechRecognitionEngine.RequestRecognizerUpdate方法代码示例

本文整理汇总了C#中SpeechRecognitionEngine.RequestRecognizerUpdate方法的典型用法代码示例。如果您正苦于以下问题:C# SpeechRecognitionEngine.RequestRecognizerUpdate方法的具体用法?C# SpeechRecognitionEngine.RequestRecognizerUpdate怎么用?C# SpeechRecognitionEngine.RequestRecognizerUpdate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SpeechRecognitionEngine的用法示例。


在下文中一共展示了SpeechRecognitionEngine.RequestRecognizerUpdate方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: button1_Click

 private void button1_Click(object sender, EventArgs e)
 {
     _completed = new ManualResetEvent(false);
     SpeechRecognitionEngine _recognizer = new SpeechRecognitionEngine();
     _recognizer.RequestRecognizerUpdate(); // request for recognizer update
     _recognizer.LoadGrammar(new Grammar(new GrammarBuilder("test"))); // load a grammar
     _recognizer.RequestRecognizerUpdate(); // request for recognizer update
     _recognizer.LoadGrammar(new Grammar(new GrammarBuilder("exit"))); // load a "exit" grammar
     _recognizer.SpeechRecognized += _recognizer_SpeechRecognized;
     _recognizer.SetInputToDefaultAudioDevice(); // set the input of the speech recognizer to the default audio device
     _recognizer.RecognizeAsync(RecognizeMode.Multiple); // recognize speech asynchronous
     _completed.WaitOne(); // wait until speech recognition is completed
     _recognizer.Dispose(); // dispose the speech recognition engine
 }
开发者ID:Benache,项目名称:Telemachus,代码行数:14,代码来源:frmMain.cs

示例2: MainWindow

        public MainWindow()
        {
            InitializeComponent();

            var config = new JsonConfigHandler( System.IO.Path.Combine( Environment.GetFolderPath( Environment.SpecialFolder.ApplicationData ), "LeagueTag" ) );
            //config.Populate();
            config.Save();
            //config.Save(
            return;
            var engine = new SpeechRecognitionEngine();

            var builder = new GrammarBuilder();
            builder.Append( "tag" );
            builder.Append( new Choices( "baron", "dragon" ) );

            engine.RequestRecognizerUpdate();
            engine.LoadGrammar( new Grammar( builder ) );

            engine.SpeechRecognized += engine_SpeechRecognized;

            engine.SetInputToDefaultAudioDevice();
            engine.RecognizeAsync( RecognizeMode.Multiple );

            CompositionTarget.Rendering += CompositionTarget_Rendering;

            this.DataContext = this;
        }
开发者ID:upta,项目名称:LeagueTag,代码行数:27,代码来源:MainWindow.xaml.cs

示例3: voiceChat

        public SpeechRecognitionEngine recog; // Speech Recognition Engine. If it wasn't "Engine" it would use the windows implementation.

        #endregion Fields

        #region Constructors

        public voiceChat(string locale)
        {
            InitializeComponent();
            this.StartPosition = FormStartPosition.CenterScreen;
            recog = new SpeechRecognitionEngine(new System.Globalization.CultureInfo(locale));  // Loads the localisation information.
            recog.RequestRecognizerUpdate();                                                    // Required to update the voice recognition.

            recog.LoadGrammar(new Grammar(new GrammarBuilder("close voice chat")));
            recog.LoadGrammar(new Grammar(new GrammarBuilder("clear chat")));
            recog.LoadGrammar(new Grammar(new GrammarBuilder("send chat")));
            recog.LoadGrammar(new DictationGrammar());

            recog.SpeechDetected += recog_SpeechDetected;                                        // Event when speech is detected. Not recgonized, just detected.
            recog.SpeechRecognized += recog_SpeechRecognized;                                   // Event when a word is found. Any processing is over there.
            recog.SetInputToDefaultAudioDevice();                                               // This sets us to the default microphone set in the Windows audio panel.
            recog.RecognizeAsync(RecognizeMode.Multiple);                                       // This just makes voice recognition work beautifully. Just leave it alone.
        }
开发者ID:unixcrh,项目名称:SteamVoiceDriver,代码行数:23,代码来源:VoiceChatForm.cs

示例4: button1_Click

        private void button1_Click(object sender, EventArgs e)
        {
            SpeechSynthesizer sSynth = new SpeechSynthesizer();
            PromptBuilder pBuilder = new PromptBuilder();
            SpeechRecognitionEngine sRecognize = new SpeechRecognitionEngine();

            Choices NumbersCh = new Choices();
            for (int i = -999; i < 1000; i++)
            {
                NumbersCh.Add(i.ToString());
            }
            NumbersCh.Add("Times");
            NumbersCh.Add("Multiply");
            NumbersCh.Add("Divided");
            NumbersCh.Add("Divide");
            NumbersCh.Add("Plus");
            NumbersCh.Add("Minus");
            NumbersCh.Add("Add");
            NumbersCh.Add("Subtract");
            NumbersCh.Add("Power");
            NumbersCh.Add("Left Over");
            Choices OperatorCh = new Choices();
            Grammar MathGr = new Grammar(new GrammarBuilder(NumbersCh));

            Choices MainCh = new Choices();
            MainCh.Add(new string[] { "Jack Hello" });
            MainCh.Add(new string[] { "Jack Launch Chrome" });
            MainCh.Add(new string[] { "Jack Go To My Facebook" });
            MainCh.Add(new string[] { "Jack Launch Go" });
            MainCh.Add(new string[] { "Jack Launch Rim World" });
            MainCh.Add(new string[] { "Jack Launch Rust" });
            MainCh.Add(new string[] { "Jack Launch Sins" });
            MainCh.Add(new string[] { "Jack Launch K S P" });
            MainCh.Add(new string[] { "Jack Launch Skype" });
            MainCh.Add(new string[] { "Jack Launch Unity" });
            MainCh.Add(new string[] { "Jack Wake Up" });
            MainCh.Add(new string[] { "That will be all for now" });
            MainCh.Add(new string[] { "Jack Close Window" });
            MainCh.Add(new string[] { "Jack Save Progress" });
            MainCh.Add(new string[] { "Alt Tab" });
            MainCh.Add(new string[] { "Jack Tell A Joke" });
            MainCh.Add(new string[] { "That Was A Good One Jack" });
            MainCh.Add(new string[] { "Jack You Are Funny" });
            MainCh.Add(new string[] { "Enter My Number" });
            MainCh.Add(new string[] { "What Are My Numbers?" });
            MainCh.Add(new string[] { "What Is My Answer?" });
            MainCh.Add(new string[] { "Jack Lock" });
            MainCh.Add(new string[] { "Jack Exit" });
            Grammar MainGr = new Grammar(new GrammarBuilder(MainCh));
            try
            {
                sRecognize.RequestRecognizerUpdate();
                sRecognize.LoadGrammar(MainGr);
                sRecognize.LoadGrammar(MathGr);
                sRecognize.SpeechRecognized += sRecognize_SpeechRecognized;
                sRecognize.SetInputToDefaultAudioDevice();
                sRecognize.RecognizeAsync(RecognizeMode.Multiple);
                sRecognize.Recognize();
            }

            catch
            {
                return;
            }
        }
开发者ID:Kmann180,项目名称:SpeechRec,代码行数:65,代码来源:Form1.cs

示例5: createSpeechRecogntionEngine

        private SpeechRecognitionEngine createSpeechRecogntionEngine(MainSystemTray form)
        {
            SpeechRecognitionEngine newSpeechRecognizer = new SpeechRecognitionEngine(CultureInfo.CurrentCulture);

            //Setting up the grammars for the voice recognizer
            Grammar commandGrammar = createCommandGrammar();
            commandGrammar.Weight = 1f;

            //"grammar:dictation#pronunciation"
            Grammar dictationGrammar = new DictationGrammar("grammar:dictation");
            dictationGrammar.Name = DictationState.GRAMMARNAME;
            dictationGrammar.Weight = .3f;

            //Setting up the voice recognizer to start listening for commands and send them to the SpeechRecognised method
            newSpeechRecognizer.RequestRecognizerUpdate();
            newSpeechRecognizer.LoadGrammar(commandGrammar);
            newSpeechRecognizer.LoadGrammar(dictationGrammar);
            try
            {
                newSpeechRecognizer.SetInputToDefaultAudioDevice();
                newSpeechRecognizer.RecognizeAsync(RecognizeMode.Multiple);
            }
            catch (System.InvalidOperationException)
            {
                if (MessageBox.Show(
                    "You do not have an audio capture device installed \nPlease install a microphone and restart the program",
                    "No Capture Device", MessageBoxButtons.OK) == DialogResult.OK)
                {
                    form.ExitProgram();
                }

            }

            return newSpeechRecognizer;
        }
开发者ID:AlexanderMcNeill,项目名称:voxvisio,代码行数:35,代码来源:MainEngine.cs

示例6: game

        private void game(int pos)
        {
            answerLabel.Text = null;
            pointsLabel.Text = points.ToString();
            sre = new SpeechRecognitionEngine();
            Choices sList = new Choices();

            String[] letters = getLetters(words[pos]);
            //label1.Text = words[pos];
            //label2.Text = pos.ToString();
            jumbledWordLabel.Text = scrambleLetters(words[pos]);
            wordPicBox.ImageLocation = "Class" + LoginForm.classSec + "_kidSpellImages/" + words[pos] + ".jpg";
            this.wordPicBox.SizeMode = PictureBoxSizeMode.Zoom;

            askQuestion(words[pos]);
            sList.Add(letters);

            Grammar gr = new Grammar(new GrammarBuilder(sList));

            try
            {
                sre.RequestRecognizerUpdate();
                sre.LoadGrammar(gr);
                sre.SpeechRecognized += rec_SpeechRecognized;
                sre.SetInputToDefaultAudioDevice();
                sre.RecognizeAsync(RecognizeMode.Multiple);
            }
            catch (Exception)
            {
                throw;
            }
        }
开发者ID:MegaColorBoy,项目名称:ProjectTaleem,代码行数:32,代码来源:SpellingGame.cs

示例7: button1_Click

        public void button1_Click(object sender, EventArgs e)
        {
            button1.Enabled = false;
            button1.Text = "God Called";
            label2.Text = "The god is listening...";
            label2.ForeColor = Color.Red;

            SpeechRecognitionEngine GodListener = new SpeechRecognitionEngine();

            Choices GodList = new Choices();
            GodList.Add(new string[] { "Make toast", "Make me toast", "Make me some toast", "Make me immortal", "Make rain", "call rain", "call the rain", "make it rain", "wink out of existence", "begone", "go now", "wink yourself out of existence" });

            GrammarBuilder gb = new GrammarBuilder();
            gb.Append(GodList);

            Grammar GodGrammar = new Grammar(gb);

            GodListener.MaxAlternates = 2;

            try
            {
                GodListener.RequestRecognizerUpdate();
                GodListener.LoadGrammar(GodGrammar);
                GodListener.SetInputToDefaultAudioDevice();
                GodListener.SpeechRecognized += GodListener_SpeechRecognized;
                GodListener.AudioStateChanged += GodListener_AudioStateChanged;
                GodListener.AudioLevelUpdated += GodListener_AudioLevelUpdated;
                GodListener.RecognizeAsync(RecognizeMode.Multiple);
            }
            catch
            {
                return;
            }
        }
开发者ID:bonfiredog,项目名称:knole,代码行数:34,代码来源:Form1.cs

示例8: button1_Click

        public void button1_Click(object sender, EventArgs e)
        {
            button1.Enabled = false;
            button1.Text = "God Called";
            label2.Text = "The god is listening...";
            label2.ForeColor = Color.Red;

            SpeechRecognitionEngine GodListener = new SpeechRecognitionEngine(new System.Globalization.CultureInfo("en-UK"));
            DictationGrammar GodGrammar = new DictationGrammar();

            GodListener.MaxAlternates = 2;

            try
            {
                GodListener.RequestRecognizerUpdate();
                GodListener.LoadGrammar(GodGrammar);
                GodListener.SetInputToDefaultAudioDevice();
                GodListener.SpeechRecognized += GodListener_SpeechRecognized;
                GodListener.AudioStateChanged += GodListener_AudioStateChanged;
                GodListener.AudioLevelUpdated += GodListener_AudioLevelUpdated;
                GodListener.RecognizeAsync(RecognizeMode.Multiple);
            }
            catch
            {
                return;
            }
        }
开发者ID:bonfiredog,项目名称:knole,代码行数:27,代码来源:Form1.cs

示例9: Form1

        public Form1()
        {
            SpeechRecognitionEngine rec = new SpeechRecognitionEngine();
            Choices list = new Choices();

            list.Add(new String[] { "hello", "how are you" , "i'm fine" });

            Grammar gr = new Grammar(new GrammarBuilder(list));

            try
            {

                rec.RequestRecognizerUpdate();
                rec.LoadGrammar(gr);
                rec.SpeechRecognized += rec_SpeechRecognized;
                rec.SetInputToDefaultAudioDevice();
                rec.RecognizeAsync(RecognizeMode.Multiple);

            }
            catch { return; }

            s.SelectVoiceByHints(VoiceGender.Female);
            s.Speak("Hello , My name is VoiceBot");

            InitializeComponent();
        }
开发者ID:NaoEdoJose,项目名称:Voice-recognition-software,代码行数:26,代码来源:Form1.cs


注:本文中的SpeechRecognitionEngine.RequestRecognizerUpdate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。