/// <summary> /// Creates and initializes a WebRTC voice activity detector. /// </summary> /// <remarks> /// This constructor injects a WebRTC library for unit testing, rather than /// depending on the P/Invoke implementation provided by the default constructor. /// </remarks> /// <param name="library">Interface for the underlying WebRTC library.</param> public WebRtcVad(IWebRtcDll library) { _webrtc = library ?? throw new ArgumentNullException(nameof(library)); _mode = OperatingMode.HighQuality; _rate = SampleRate.Is8kHz; _length = FrameLength.Is10ms; try { _handle = _webrtc.Create(); var result = _webrtc.Init(_handle); ValidateInitialize(result, _handle); } catch (DllNotFoundException e) { var currentDir = Directory.GetCurrentDirectory(); throw new DllNotFoundException($"Unable to load DLL 'WebRtcVad.dll' or a dependency. Be sure it exists in '{currentDir}' or elsewhere in the DLL search path.", e); } }
public TestWebRtcVad(IWebRtcDll library) : base(library) { }