Cobra Voice Activity Detection
Node.js API
API Reference for the Node.js Cobra SDK (npm)
Cobra
Class for the Cobra Voice Activity Detection engine.
Cobra can be initialized using the class constructor().
Resources should be cleaned when you are done using the release() method.
Cobra.constructor()
Cobra constructor.
Parameters
accessKeystring : AccessKey obtained from Picovoice Console.optionsCobraOptions: Optional configuration arguments:devicestring? : String representation of the device (e.g., CPU or GPU) to use for inference. If set tobest, the engine picks the most suitable device. 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.libraryPathstring : Path to the Cobra dynamic library (.node).
Returns
Cobra: An instance of Cobra platform.
Cobra.release()
Releases resources acquired by Cobra.
Cobra.frameLength
Getter for number of audio samples per frame.
Returns
number: Number of audio samples per frame.
Cobra.sampleRate
Getter for audio sample rate accepted by Cobra.
Returns
number: Audio sample rate accepted by Cobra.
Cobra.version
Getter for version.
Returns
string: CurrentCobraversion.
Cobra.process()
Processes a frame of the incoming audio stream with the voice activity detection engine. The number of samples per frame can be attained 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
pcmArray<number> : A frame of audio samples.
Returns
number: Probability of voice activity. It is a floating-point number within [0, 1].
Cobra.listAvailableDevices()
Lists all available devices that Cobra can use for inference. Each entry in the list can be the device argument of the constructor.
Parameters
optionsCobraInputOptions : Optional input configuration arguments.
Returns
- string[] : List of all available devices that Cobra can use for inference.
Errors
Exceptions thrown if an error occurs within Cobra Voice Activity Detection engine.
Exceptions: