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
accessKey
string : AccessKey obtained from Picovoice Console.options
CobraOptions: Optional configuration arguments:libraryPath
string : 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
: CurrentCobra
version.
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
pcm
Array<number> : A frame of audio samples.
Returns
number
: Probability of voice activity. It is a floating-point number within [0, 1].
Errors
Exceptions thrown if an error occurs within Cobra
Voice Activity Detection engine.
Exceptions: