Cobra Voice Activity Detection
.NET API
API Reference for the Cobra .NET SDK (NuGet).
Cobra
Class for the Cobra VAD engine.
Cobra.Cobra()
Constructor method for the Cobra voice activity detection (VAD) engine.
Parameters
accessKeystr : AccessKey obtained from Picovoice Console.devicestring : String representation of the device (e.g., CPU or GPU) to use. If set tobest, the most suitable device is selected automatically. If set togpu, the engine uses the first available GPU device. To select a specific GPU device, set this argument togpu:${GPU_INDEX}, where${GPU_INDEX}is the index of the target GPU. If set tocpu, the engine will run on the CPU with the default number of threads. To specify the number of threads, set this argument tocpu:${NUM_THREADS}, where${NUM_THREADS}is the desired number of threads.
Returns
Cobra: An instance of Cobra VAD engine.
Throws
Cobra.FrameLength
The number of audio samples per frame that Cobra accepts.
Cobra.SampleRate
The audio sample rate the Cobra accepts.
Cobra.Version
The Cobra library version string.
Cobra.GetAvailableDevices()
Retrieves a list of hardware devices that can be specified when constructing Cobra.
Returns
string[]: An array of available hardware devices.
Throws
CobraException: If an error occurs while retrieving the hardware devices.
Cobra.Dispose()
Releases resources acquired by Cobra.
Cobra.Process()
Processes a frame of the incoming audio stream and emits the detection result.
The required number of samples-per-frame can be obtained by calling .FrameLength.
The incoming audio needs to have a sample rate equal to .SampleRate and be 16-bit linearly-encoded.
Cobra operates on single-channel audio.
Parameters
pcmshort[] : A frame of audio samples.
Returns
float: Probability of voice activity. It is a floating-point number within [0, 1].
Throws
CobraException
Error thrown if an error occurs within Cobra VAD engine.
Exceptions