Exemple #1
0
 // 停止の初期化
 private void CloseVideoSource()
 {
     if (!(videoSource == null))
     {
         if (videoSource.IsRunning)
         {
             videoSource.SignalToStop();
             videoSource.WaitForStop();
             videoSource = null;
             Console.Out.WriteLine("videoSource Disposed");
         }
     }
     if (!(audioSource == null))
     {
         if (audioSource.IsRunning)
         {
             audioSource.SignalToStop();
             audioSource.WaitForStop();
         }
         audioSource.Dispose();
         audioSource = null;
         Console.Out.WriteLine("audioSource Disposed");
     }
     finalizeXAudio2();
 }
Exemple #2
0
        private async void OnListeningAsync()
        {
            Console.WriteLine("Press key to stop this shit!");
            // Wait until operations end
            var finishEventTask = new Task(FinishRecord);

            finishEventTask.Start();
            await finishEventTask;

            Thread.Sleep(500); // For capturing last signals
            _microphone.SignalToStop();
        }
 public void Stop()
 {
     _stopwatch.Stop();
     _recognizer.Recognizing         -= OnSpeechRecognized;
     _recognizer.Recognized          -= OnSpeechRecognized;
     _recognizer.SpeechStartDetected -= OnSpeechStartDetected;
     _recognizer.Canceled            -= OnRecognitionCancelled;
     _audioCapture.NewFrame          -= OnAudioFrameCaptured;
     _audioCapture.SignalToStop();
     _audioCapture.WaitForStop();
     _recognizer.StopContinuousRecognitionAsync().Wait();
 }
Exemple #4
0
        private void StopVoiceCapture()
        {
            AudioCapture.SignalToStop();

            FrameRate    = (double)BitmapsCount / _waveEncoder.Duration * 1000;
            BitmapsCount = 0;

            AudioCapture.NewFrame         -= NewAudioFrame;
            AudioCapture.AudioSourceError -= AudioError;
            AudioCapture = null;
            _waveEncoder = null;
            _audioStream.Close();
            _audioStream = null;
            stopAll     -= StopVoiceCapture;
        }
        private void doAudioStop()
        {
            // Stops both cases
            if (AudioSource != null)
            {
                // If we were recording
                AudioSource.SignalToStop();
                AudioSource.WaitForStop();
            }


            var fileStream = File.Create(filenameAudio);

            stream.WriteTo(fileStream);
            fileStream.Close();

            // Also zero out the buffers and screen
            Array.Clear(current, 0, current.Length);
        }