private void startRecordingButton_Click(object sender, EventArgs e)
 {
     if (wavRecorder == null)
     {
         wavRecorder                 = new 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)
             {
                 WAVSound sound = new WAVSound("", wavRecorder.SampleRate, wavRecorder.NumberOfChannels, wavRecorder.NumberOfBitsPerSample);
                 sound.AppendSamplesAsBytes(recordedBytes);
                 sound.SetMaximumNonClippingVolume();
                 soundVisualizer.SetSound(sound);
             }
         }
         recordingButton.Text    = "Start recording";
         recognizeButton.Enabled = true;
     }
 }
 private void recordToolStripButton_Click(object sender, EventArgs e)
 {
     if (recordToolStripButton.Text.Contains("Start"))  // A bit ugly, but OK
     {
         recordToolStripButton.Text = "Stop recording";
         wavRecorder          = new WAVRecorder();
         wavRecorder.DeviceId = 0;
         wavRecorder.Start();
     }
     else
     {
         wavRecorder.Stop();
         byte[] recordedBytes = wavRecorder.GetAllRecordedBytes();
         if (recordedBytes != null)
         {
             if (recordedBytes.Length > 0)
             {
                 WAVSound sound = new WAVSound("", wavRecorder.SampleRate, wavRecorder.NumberOfChannels, wavRecorder.NumberOfBitsPerSample);
                 sound.AppendSamplesAsBytes(recordedBytes);
                 soundVisualizer.SetSound(sound);
             }
         }
         recordToolStripButton.Text         = "Start recording";
         playSoundButton.Enabled            = true;
         saveSoundToolStripMenuItem.Enabled = true;
     }
 }
 public void StartRecording()
 {
     // Start recording
     recorder   = new WAVRecorder(AudioSettings.outputSampleRate, (int)AudioSettings.speakerMode);
     audioInput = new AudioInput(recorder, microphoneSource, true);
     // Unmute microphone
     microphoneSource.mute = false;
 }
        public void Start()
        {
            if (running)
            {
                return;
            }

            wavRecorder                 = new WAVRecorder();
            wavRecorder.DeviceId        = recordingDeviceID;
            wavRecorder.StorageDuration = storageDuration;
            wavRecorder.Start();

            runThread = new Thread(new ThreadStart(() => RunLoop()));
            running   = true;
            runThread.Start();
        }
Esempio n. 5
0
        private void Initialize()
        {
            Size screenSize = Screen.GetBounds(this).Size;

            this.Location = new Point(screenSize.Width - this.Width, screenSize.Height - this.Height);
            mainTabControl.SelectedTab = inputTabPage;
            continuousSpeechRecognitionControl.SoundRecognized += new EventHandler <StringEventArgs>(HandleContinuousSoundRecognized);
            continuousSpeechRecognitionControl.SoundDetected   += new EventHandler <WAVSoundEventArgs>(HandleContinuousSoundDetected);
            List <string> recordingDeviceNameList = WAVRecorder.GetDeviceNames();

            recordingDeviceComboBox.Items.Clear();
            foreach (string recordingDeviceName in recordingDeviceNameList)
            {
                recordingDeviceComboBox.Items.Add(recordingDeviceName);
            }
            if (recordingDeviceNameList.Count > 0)
            {
                recordingDeviceComboBox.SelectedIndex = recordingDeviceID;
            }
            clientBusy = false;
        }
Esempio n. 6
0
 void Start()
 {
     rc      = cam.GetComponent <WAVRecorder> ();
     recTime = 0;
     InitGame();
 }