Picovoice Wordmark
Start Building
Introduction
Introduction
AndroidC.NETiOSLinuxmacOSNode.jsPythonRaspberry PiWebWindows
AndroidC.NETiOSNode.jsPythonWeb
SummaryPicovoice picoLLMGPTQ
Introduction
AndroidC.NETFlutteriOSJavaLinuxmacOSNode.jsPythonRaspberry PiReactReact NativeRustWebWindows
AndroidC.NETFlutteriOSJavaNode.jsPythonReactReact NativeRustWeb
SummaryPicovoice LeopardAmazon TranscribeAzure Speech-to-TextGoogle ASRGoogle ASR (Enhanced)IBM Watson Speech-to-TextWhisper Speech-to-Text
FAQ
Introduction
AndroidC.NETFlutteriOSJavaLinuxmacOSNode.jsPythonRaspberry PiReactReact NativeRustWebWindows
AndroidC.NETFlutteriOSJavaNode.jsPythonReactReact NativeRustWeb
SummaryPicovoice Cheetah
FAQ
Introduction
AndroidC.NETiOSLinuxmacOSNode.jsPythonRaspberry PiWebWindows
AndroidC.NETiOSNode.jsPythonWeb
SummaryAmazon PollyAzure TTSElevenLabsOpenAI TTSPicovoice Orca
Introduction
AndroidCiOSLinuxmacOSPythonRaspberry PiWebWindows
AndroidCiOSPythonWeb
SummaryPicovoice KoalaMozilla RNNoise
Introduction
AndroidCiOSLinuxmacOSNode.jsPythonRaspberry PiWebWindows
AndroidCNode.jsPythoniOSWeb
SummaryPicovoice EaglepyannoteSpeechBrainWeSpeaker
Introduction
AndroidCiOSLinuxmacOSPythonRaspberry PiWebWindows
AndroidCiOSPythonWeb
SummaryPicovoice FalconAmazon TranscribeAzure Speech-to-TextGoogle Speech-to-Textpyannote
Introduction
AndroidArduinoCChrome.NETEdgeFirefoxFlutteriOSJavaLinuxmacOSMicrocontrollerNode.jsPythonRaspberry PiReactReact NativeRustSafariUnityWebWindows
AndroidC.NETFlutteriOSJavaMicrocontrollerNode.jsPythonReactReact NativeRustUnityWeb
SummaryPorcupineSnowboyPocketSphinx
Wake Word TipsFAQ
Introduction
AndroidCChrome.NETEdgeFirefoxFlutteriOSJavaLinuxmacOSNode.jsPythonRaspberry PiReactReact NativeRustSafariUnityWebWindows
AndroidC.NETFlutteriOSJavaNode.jsPythonReactReact NativeRustUnityWeb
SummaryPicovoice RhinoGoogle DialogflowAmazon LexIBM WatsonMicrosoft LUIS
Expression SyntaxFAQ
Introduction
AndroidC.NETiOSLinuxmacOSNode.jsPythonRaspberry PiRustWebWindows
AndroidC.NETiOSNode.jsPythonRustWeb
SummaryPicovoice CobraWebRTC VAD
FAQ
Introduction
AndroidC.NETFlutteriOSNode.jsPythonReact NativeRustUnityWeb
AndroidC.NETFlutteriOSNode.jsPythonReact NativeRustUnityWeb
Introduction
C.NETNode.jsPython
C.NETNode.jsPython
FAQGlossary

Cobra Voice Activity Detection
Rust API

Rust SDKs will no longer be maintained after July 15, 2025. If you plan to use the Cobra Voice Activity Detection Rust SDK for commercial purposes, please contact us.

API Reference for the Cobra Rust SDK (crates.io).


cobra::Cobra

pub struct Cobra

Struct for the Cobra VAD engine.


cobra::Cobra.new()

pub fn new<S: Into<String>>(access_key: S) -> Result<Cobra, CobraError>

Creates a new Cobra from required arguments.

Parameters

  • access_key S : AccessKey obtained from Picovoice Console.

Returns

  • Result<Cobra, CobraError> : If Ok, returns a new Cobra object. If Err, a CobraError object describing the error that was encountered.

cobra::Cobra.new_with_library()

pub fn new_with_library<S: Into<String>, P: Into<PathBuf>>(access_key: S, library_path: P) -> Result<Cobra, CobraError>

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> : If Ok, returns a new Cobra object. If Err, a CobraError object describing the error that was encountered.

cobra::Cobra.process()

pub fn process(&self, pcm: &[i16]) -> Result<f32, CobraError>

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> : If Ok, returns the probability of voice activity. It is a floating-point number within [0, 1]. If Err, a CobraError object describing the error that was encountered.

cobra::Cobra.frame_length()

pub fn frame_length(&self) -> u32

Gets the frame length.

Returns

  • u32 : Audio frame length accepted by Cobra.

cobra::Cobra.sample_rate()

pub fn sample_rate(&self) -> u32

Gets the sample rate.

Returns

  • u32 : Audio sample rate accepted by Cobra.

cobra::Cobra.version()

pub fn version(&self) -> &str

Gets the Cobra version.

Returns

  • &str : Cobra version string.

cobra::CobraError

pub struct CobraError

An error type describing any errors encountered by the Cobra SDK.


cobra::CobraError.new()

pub fn new(status: CobraErrorStatus, message: impl Into<String>) -> Self

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

pub enum CobraErrorStatus {
LibraryError(PvStatus),
LibraryLoadError,
FrameLengthError,
ArgumentError,
}

Enum describing possible error types returned from the Cobra Rust SDK.


cobra::PvStatus

pub enum PvStatus {
SUCCESS = 0,
OUT_OF_MEMORY = 1,
IO_ERROR = 2,
INVALID_ARGUMENT = 3,
STOP_ITERATION = 4,
KEY_ERROR = 5,
INVALID_STATE = 6,
PV_STATUS_RUNTIME_ERROR = 7,
PV_STATUS_ACTIVATION_ERROR = 8,
PV_STATUS_ACTIVATION_LIMIT_REACHED = 9,
PV_STATUS_ACTIVATION_THROTTLED = 10,
PV_STATUS_ACTIVATION_REFUSED = 11,
}

Error codes returned from the Cobra library.

Was this doc helpful?

Issue with this doc?

Report a GitHub Issue
Cobra Voice Activity Detection Rust API
  • cobra::Cobra
  • new()
  • new_with_library()
  • process()
  • frame_length()
  • sample_rate()
  • version()
  • cobra::CobraError
  • new()
  • cobra::CobraErrorStatus
  • cobra::PvStatus
Voice AI
  • Leopard Speech-to-Text
  • Cheetah Streaming Speech-to-Text
  • Orca Text-to-Speech
  • Koala Noise Suppression
  • Eagle Speaker Recognition
  • Falcon Speaker Diarization
  • Porcupine Wake Word
  • Rhino Speech-to-Intent
  • Cobra Voice Activity Detection
Local LLM
  • picoLLM Inference
  • picoLLM Compression
  • picoLLM GYM
Resources
  • Docs
  • Console
  • Blog
  • Use Cases
  • Playground
Sales & Services
  • Consulting
  • Foundation Plan
  • Enterprise Plan
  • Enterprise Support
Company
  • About us
  • Careers
Follow Picovoice
  • LinkedIn
  • GitHub
  • X
  • YouTube
  • AngelList
Subscribe to our newsletter
Terms of Use
Privacy Policy
© 2019-2025 Picovoice Inc.