Cobra Voice Activity Detection Engine

Made in Vancouver, Canada by Picovoice

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

Compatibility

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: toml [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:

```rust use cobra::Cobra;

let accesskey = "..."; // AccessKey provided by Picovoice Console (https://console.picovoice.ai/) let cobra = Cobra::new(accesskey); `` whereaccess_keyis an AccessKey which should be obtained from [Picovoice Console](https://console.picovoice.ai/).cobra` is an instance of Cobra that detects voice activities.

```rust fn nextaudioframe() -> Vec { // get audio frame }

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

loop { if let Ok(voiceprobability) = cobra.process(&nextaudioframe()) { if voiceprobability >= threshold { // Detection event! } } } ```

Use new_with_library to override the default library path:

```rust use cobra::Cobra;

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

Demos

Check out the Cobra Rust demos here