Crates.io | pv_cobra |
lib.rs | pv_cobra |
version | 2.0.3 |
source | src |
created_at | 2021-10-07 23:23:55.828604 |
updated_at | 2024-09-04 18:27:02.959527 |
description | The Rust bindings for Picovoice's Cobra library |
homepage | https://picovoice.ai/platform/cobra/ |
repository | https://github.com/Picovoice/cobra |
max_upload_size | |
id | 462119 |
size | 2,699,703 |
Made in Vancouver, Canada by Picovoice
Cobra is a highly accurate and lightweight voice activity detection (VAD) engine.
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 = "*"
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
.
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");
Check out the Cobra Rust demos here