private void LoadGrammar() { global::System.Speech.Recognition.Choices choices = new global::System.Speech.Recognition.Choices(); global::System.Collections.Generic.List <string> phraseList = new global::System.Collections.Generic.List <string>(); for (int ii = 0; ii < grammarPhraseListBox.Items.Count; ii++) { string phrase = grammarPhraseListBox.Items[ii].ToString(); phraseList.Add(phrase); } choices.Add(phraseList.ToArray()); if (phraseList.Count > 0) { global::System.Speech.Recognition.GrammarBuilder grammarBuilder = new global::System.Speech.Recognition.GrammarBuilder(); global::System.Globalization.CultureInfo currentCulture = new global::System.Globalization.CultureInfo("en-US"); grammarBuilder.Culture = currentCulture; grammarBuilder.Append(choices); global::System.Speech.Recognition.Grammar grammar = new global::System.Speech.Recognition.Grammar(grammarBuilder); speechRecognitionEngine.LoadGrammar(grammar); // speechRecognitionEngine.LoadGrammar(new DictationGrammar()); recognizeButton.Enabled = true; } else { recognizeButton.Enabled = false; } }
private void Initialize() { global::System.Drawing.Size screenSize = global::System.Windows.Forms.Screen.GetBounds(this).Size; this.Location = new global::System.Drawing.Point(screenSize.Width - this.Width, screenSize.Height - this.Height); mainTabControl.SelectedTab = inputTabPage; continuousSpeechRecognitionControl.SoundRecognized += new global::System.EventHandler <global::AuxiliaryLibrary.StringEventArgs>(HandleContinuousSoundRecognized); continuousSpeechRecognitionControl.SoundDetected += new global::System.EventHandler <global::AudioLibrary.WAVSoundEventArgs>(HandleContinuousSoundDetected); global::System.Collections.Generic.List <string> recordingDeviceNameList = global::AudioLibrary.WAVRecorder.GetDeviceNames(); recordingDeviceComboBox.Items.Clear(); foreach (string recordingDeviceName in recordingDeviceNameList) { recordingDeviceComboBox.Items.Add(recordingDeviceName); } if (recordingDeviceNameList.Count > 0) { recordingDeviceComboBox.SelectedIndex = recordingDeviceID; } clientBusy = false; }