Cobra Voice Activity Detection
Android API
API Reference for the Android Cobra SDK (cobra-android)
package: ai.picovoice.cobra
Cobra
Class for the Cobra VAD engine.
Cobra must be initialized using the Builder() Class. Resources should be cleaned when you are done using the delete() function.
Cobra.getAvailableDevices()
Lists all available devices that Cobra can use for inference.
Each entry in the list can be used as the device argument when initializing Cobra.
Returns
String[]: Array of all available devices thatCobracan be used for inference.
Throws
CobraException: If an error occurs while getting available devices.
Cobra.getFrameLength()
Getter for required number of audio samples per frame.
Returns
int: Required number of audio samples per frame.
Cobra.getSampleRate()
Getter for required audio sample rate
Returns
int: Required audio sample rate.
Cobra.getVersion()
Getter for Cobra version.
Returns
String: Cobra version.
Cobra.delete()
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 .getFrameLength().
The incoming audio needs to have a sample rate equal to .getSampleRate() 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: If an error occurs while processing.
Cobra.Builder
Builder for creating an instance of Cobra with a mixture of default arguments.
Cobra.Builder.build()
Creates an instance of Cobra VAD engine.
Returns
Cobra: An instance of Cobra VAD engine.
Throws
CobraException: If an error occurs while creating an instance of Cobra VAD engine.
Cobra.Builder.setAccessKey()
Sets the AccessKey of the builder.
Parameters
accessKeyString : AccessKey obtained from Picovoice Console.
Returns
Cobra.Builder: Modified Cobra.Builder object.
Cobra.Builder.setDevice()
Sets the device of the builder. If not set it will be set to the default device.
Parameters
deviceString : String representation of the device (e.g., CPU or GPU) to use.
Returns
Cobra.Builder: Modified Cobra.Builder object.
CobraException
Exception thrown if an error occurs within Cobra VAD engine.
Exceptions