static void ProcessStream(VoiceActivityDetectorV2 vad, Stream inputStream) { var bufferSize = 3200; var buffer = new byte[bufferSize]; int bytesRead = 0; bytesRead = inputStream.Read(buffer, 0, bufferSize); while (bytesRead > 0) { vad.ProcessBuffer(buffer, bytesRead); bytesRead = inputStream.Read(buffer, 0, bufferSize); } }
//[Test] Yet not implemented public void TestVAD2() { var vad = new VoiceActivityDetectorV2(SAMPLE_RATE); vad.Enabled = false; var inputStream = ReadFileFromResource("speech.raw"); speechEnd = false; speechBegin = false; vad.SpeechBegin += () => { speechBegin = true; }; vad.SpeechEnd += () => { speechEnd = true; }; ProcessStream(vad, inputStream); Assert.IsTrue(speechBegin); Assert.IsFalse(speechEnd); }
static void ProcessStream(VoiceActivityDetectorV2 vad, Stream inputStream) { var bufferSize = 3200; var buffer = new byte[bufferSize]; int bytesRead = 0; bytesRead = inputStream.Read(buffer, 0, bufferSize); while (bytesRead > 0) { vad.ProcessBuffer(buffer, bytesRead); bytesRead = inputStream.Read(buffer, 0, bufferSize); } }
//[Test] Yet not implemented public void TestVAD2() { var vad = new VoiceActivityDetectorV2(SAMPLE_RATE); vad.Enabled = false; var inputStream = ReadFileFromResource("speech.raw"); speechEnd = false; speechBegin = false; vad.SpeechBegin += () => {speechBegin = true; }; vad.SpeechEnd += () => {speechEnd = true; }; ProcessStream(vad, inputStream); Assert.IsTrue(speechBegin); Assert.IsFalse(speechEnd); }