private void continuousInputStopButton_Click(object sender, global::System.EventArgs e)
 {
     continuousInputStopButton.Enabled = false;
     continuousSpeechRecognitionControl.Stop();
     continuousInputButton.Enabled   = true;
     recordingDeviceComboBox.Enabled = true;
 }
 private void recordingButton_Click(object sender, global::System.EventArgs e)
 {
     if (wavRecorder == null)
     {
         wavRecorder                 = new global::AudioLibrary.WAVRecorder();
         wavRecorder.SampleRate      = 16000;
         wavRecorder.StorageDuration = 10;
     }
     if (!wavRecorder.IsRecording)
     {
         recognizeButton.Enabled = false;
         recordingButton.Text    = "Stop recording";
         wavRecorder.Start();
     }
     else
     {
         wavRecorder.Stop();
         byte[] recordedBytes = wavRecorder.GetAllRecordedBytes();
         if (recordedBytes != null)
         {
             if (recordedBytes.Length > 0)
             {
                 global::AudioLibrary.WAVSound recordedSound = new global::AudioLibrary.WAVSound("", wavRecorder.SampleRate, wavRecorder.NumberOfChannels, wavRecorder.NumberOfBitsPerSample);
                 recordedSound.AppendSamplesAsBytes(recordedBytes);
                 recordedSound.SetMaximumNonClippingVolume();
                 soundVisualizer.SetSound(recordedSound);
             }
         }
         recordingButton.Text    = "Start recording";
         recognizeButton.Enabled = true;
     }
 }
        protected virtual void OnAvailableChanged(global::System.EventArgs e)
        {
            var handler = AvailableChanged;

            if (handler != null)
            {
                handler(this, e);
            }
        }
        private void grammarPhraseListBox_SelectedIndexChanged(object sender, global::System.EventArgs e)
        {
            int selectedIndex = grammarPhraseListBox.SelectedIndex;

            if (selectedIndex >= 0)
            {
                grammarPhraseListBox.Items.RemoveAt(selectedIndex);
            }
        }
 private void addToGrammarButton_Click(object sender, global::System.EventArgs e)
 {
     if (grammarPhraseTextBox.Text != "")
     {
         if (!grammarPhraseListBox.Items.Contains(grammarPhraseTextBox.Text))
         {
             grammarPhraseListBox.Items.Insert(0, grammarPhraseTextBox.Text);
         }
     }
 }
        private void detectionThresholdTextBox_TextChanged(object sender, global::System.EventArgs e)
        {
            int detectionThreshold;

            global::System.Boolean ok = int.TryParse(detectionThresholdTextBox.Text, out detectionThreshold);
            if (ok)
            {
                if (detectionThreshold > 0)
                {
                    continuousSpeechRecognitionControl.DetectionThreshold = detectionThreshold;
                }
            }
        }
 private void recognizeButton_Click(object sender, global::System.EventArgs e)
 {
     if (soundVisualizer.Sound == null)
     {
         return;
     }
     soundVisualizer.Sound.GenerateMemoryStream();
     speechRecognitionEngine.SetInputToWaveStream(soundVisualizer.Sound.WAVMemoryStream);
     global::System.Speech.Recognition.RecognitionResult r = speechRecognitionEngine.Recognize();
     if (r != null)
     {
         inputTextBox.Text = r.Text;
         client.Send(r.Text);
         global::CustomUserControlsLibrary.ColorListBoxItem item = new global::CustomUserControlsLibrary.ColorListBoxItem(global::System.DateTime.Now.ToString(global::ListenerApplication.ListenerMainForm.DATETIME_FORMAT) + ": " + r.Text, inputMessageColorListBox.BackColor,
                                                                                                                          inputMessageColorListBox.ForeColor);
         inputMessageColorListBox.Items.Insert(0, item);
     }
 }
        private void continuousInputButton_Click(object sender, global::System.EventArgs e)
        {
            continuousInputButton.Enabled = false;
            grammarPhraseTextBox.Enabled  = false;
            grammarPhraseListBox.Enabled  = false;
            addToGrammarButton.Enabled    = false;
            speechRecognitionEngine       = new global::System.Speech.Recognition.SpeechRecognitionEngine();
            LoadGrammar();
            recordingDeviceComboBox.Enabled = false;
            recordingDeviceID = recordingDeviceComboBox.SelectedIndex; // 20171214
            int detectionThreshold = int.Parse(detectionThresholdTextBox.Text);

            continuousSpeechRecognitionControl.DetectionThreshold = detectionThreshold;
            continuousSpeechRecognitionControl.RecordingDeviceID  = recordingDeviceID;
            continuousSpeechRecognitionControl.SetSpeechRecognitionEngine(speechRecognitionEngine);
            continuousSpeechRecognitionControl.ShowSoundStream       = showSoundStreamToolStripMenuItem.Checked;
            continuousSpeechRecognitionControl.ExtractDetectedSounds = extractDetectedSoundsToolStripMenuItem.Checked;
            continuousSpeechRecognitionControl.Start();
            continuousInputStopButton.Enabled = true;
        }
        private void HandleConnectionEstablished(object sender, global::System.EventArgs e)
        {
            // Start continuous recognition once a connection to the server has been established
            grammarPhraseTextBox.Enabled = false;
            grammarPhraseListBox.Enabled = false;
            addToGrammarButton.Enabled   = false;
            speechRecognitionEngine      = new global::System.Speech.Recognition.SpeechRecognitionEngine();
            LoadGrammar();
            recordingDeviceComboBox.Enabled = false;
            int detectionThreshold = int.Parse(detectionThresholdTextBox.Text);

            continuousSpeechRecognitionControl.DetectionThreshold = detectionThreshold;
            continuousSpeechRecognitionControl.RecordingDeviceID  = recordingDeviceID;
            continuousSpeechRecognitionControl.SetSpeechRecognitionEngine(speechRecognitionEngine);
            continuousSpeechRecognitionControl.ShowSoundStream       = showSoundStreamToolStripMenuItem.Checked;
            continuousSpeechRecognitionControl.ExtractDetectedSounds = extractDetectedSoundsToolStripMenuItem.Checked;
            continuousSpeechRecognitionControl.Start();
            continuousInputButton.Enabled     = false;
            continuousInputStopButton.Enabled = true;
        }
 private void extractDetectedSoundsToolStripMenuItem_Click(object sender, global::System.EventArgs e)
 {
     continuousSpeechRecognitionControl.ExtractDetectedSounds = extractDetectedSoundsToolStripMenuItem.Checked;
 }
 private void showSoundStreamToolStripMenuItem_Click(object sender, global::System.EventArgs e)
 {
     continuousSpeechRecognitionControl.ShowSoundStream = showSoundStreamToolStripMenuItem.Checked;
 }
 private void exitToolStripMenuItem_Click(object sender, global::System.EventArgs e)
 {
     continuousSpeechRecognitionControl.Stop();
     global::System.Windows.Forms.Application.Exit();
 }