Cobra Voice Activity Detection
iOS API
API Reference for the Cobra iOS SDK (Cocoapods).
Cobra
Class for the Cobra VAD engine.
Cobra can be initialized using the class constructor. Resources should be cleaned when you are done using the delete()
method.
Cobra.frameLength
The number of audio samples per frame that Cobra accepts.
Cobra.sampleRate
The audio sample rate that Cobra accepts.
Cobra.version
The Cobra library version string.
Cobra.init()
init method for Cobra VAD engine.
Parameters
accessKeyString : 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.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 .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[Int16] : A frame of audio samples.
Returns
Float32: Probability of voice activity. It is a floating-point number within [0, 1].
Throws
Cobra.getAvailableDevices()
Retrieves a list of devices that can be specified when constructing Cobra.
Returns
- [String] : An array of available devices.
Throws
CobraError: If an error occurs while retrieving the devices.
CobraError
Error thrown if an error occurs within Cobra VAD engine.
Exceptions