Cobra Voice Activity Detection
Rust API
API Reference for the Cobra Rust SDK (crates.io).
cobra::Cobra
Struct for the Cobra VAD engine.
cobra::Cobra.new()
Creates a new Cobra
from required arguments.
Parameters
access_key
S : AccessKey obtained from Picovoice Console.
Returns
Result<Cobra, CobraError>
: IfOk
, returns a newCobra
object. IfErr
, aCobraError
object describing the error that was encountered.
cobra::Cobra.new_with_library()
Creates a new Cobra
from required arguments.
Parameters
access_key
S : AccessKey obtained from Picovoice Console.library_path
P : Path to the Cobra library file.
Returns
Result<Cobra, CobraError>
: IfOk
, returns a newCobra
object. IfErr
, aCobraError
object describing the error that was encountered.
cobra::Cobra.process()
Processes a frame of the incoming audio stream and emits the probability of voice activity.
The number of samples per frame can be attained by calling .frame_length
. The incoming audio needs to have a sample rate equal to .sample_rate
and be 16-bit linearly-encoded. Furthermore, Cobra operates on single-channel audio.
Parameters
pcm
&[i16] : Audio data.
Returns
Result<f32, CobraError>
: IfOk
, returns the probability of voice activity. It is a floating-point number within [0, 1]. IfErr
, aCobraError
object describing the error that was encountered.
cobra::Cobra.frame_length()
Gets the frame length.
Returns
u32
: Audio frame length accepted by Cobra.
cobra::Cobra.sample_rate()
Gets the sample rate.
Returns
u32
: Audio sample rate accepted by Cobra.
cobra::Cobra.version()
Gets the Cobra version.
Returns
&str
: Cobra version string.
cobra::CobraError
An error type describing any errors encountered by the Cobra SDK.
cobra::CobraError.new()
Creates a new instance of CobraError
Parameters
status
CobraErrorStatus
: Type of error encountered.message
impl Into<String> : Message detailing the cause of the error.
cobra::CobraErrorStatus
Enum describing possible error types returned from the Cobra Rust SDK.
cobra::PvStatus
Error codes returned from the Cobra library.