13 stable releases

2.0.3 Sep 4, 2024
2.0.2 Nov 17, 2023
2.0.1 Oct 30, 2023
1.2.1 Jun 7, 2023
0.0.2 Oct 7, 2021

#139 in Audio

Download history 136/week @ 2024-08-31 13/week @ 2024-09-07 20/week @ 2024-09-14 18/week @ 2024-09-21 11/week @ 2024-09-28 18/week @ 2024-10-05 4/week @ 2024-10-12 2/week @ 2024-11-02 1/week @ 2024-11-09 115/week @ 2024-11-30

117 downloads per month

Apache-2.0

2.5MB
450 lines

Contains (Windows DLL, 360KB) data/lib/windows/amd64/libpv_cobra.dll, (Mach-o library, 290KB) data/lib/mac/arm64/libpv_cobra.dylib, (Mach-o library, 300KB) data/lib/mac/x86_64/libpv_cobra.dylib, (ELF lib, 240KB) data/lib/linux/x86_64/libpv_cobra.so, (ELF lib, 205KB) libpv_cobra.so, (ELF lib, 210KB) libpv_cobra.so and 5 more.

Cobra Voice Activity Detection Engine

Made in Vancouver, Canada by Picovoice

Cobra is a highly accurate and lightweight voice activity detection (VAD) engine.

Compatibility

  • Rust 1.54+
  • Runs on Linux (x86_64), macOS (x86_64, arm64), Windows (x86_64), and Raspberry Pi (3, 4, 5)

Installation

First you will need Rust and Cargo installed on your system.

To add the cobra library into your app, add pv_cobra to your apps Cargo.toml manifest:

[dependencies]
pv_cobra = "*"

AccessKey

Cobra requires a valid Picovoice AccessKey at initialization. AccessKey acts as your credentials when using Cobra SDKs. You can get your AccessKey for free. Make sure to keep your AccessKey secret. Signup or Login to Picovoice Console to get your AccessKey.

Usage

Create an instance of the engine:

use cobra::Cobra;

let access_key = "..."; // AccessKey provided by Picovoice Console (https://console.picovoice.ai/)
let cobra = Cobra::new(access_key);

where access_key is an AccessKey which should be obtained from Picovoice Console. cobra is an instance of Cobra that detects voice activities.

fn next_audio_frame() -> Vec<i16> {
    // get audio frame
}

let threshold = ... // Detection threshold within [0, 1]

loop {
    if let Ok(voice_probability) = cobra.process(&next_audio_frame()) {
        if voice_probability >= threshold {
            // Detection event!
        }
    }
}

Use new_with_library to override the default library path:

use cobra::Cobra;

let access_key = "..."; // AccessKey provided by Picovoice Console (https://console.picovoice.ai/)
let cobra = Cobra::new_with_library(access_key, "/path/to/library/file");

Demos

Check out the Cobra Rust demos here

Dependencies