7 stable releases

new 2.1.0 Dec 10, 2024
2.0.3 Sep 17, 2024
2.0.2 Feb 6, 2024
2.0.0 Nov 24, 2023
0.9.0 Mar 19, 2022

#247 in Audio

Download history 31/week @ 2024-09-09 172/week @ 2024-09-16 22/week @ 2024-09-23 7/week @ 2024-09-30 1/week @ 2024-10-07 168/week @ 2024-12-02

168 downloads per month

Apache-2.0

29MB
601 lines

Contains (Windows DLL, 410KB) data/lib/windows/amd64/libpv_cheetah.dll, (ELF lib, 290KB) data/lib/linux/x86_64/libpv_cheetah.so, (Mach-o library, 320KB) data/lib/mac/arm64/libpv_cheetah.dylib, (Mach-o library, 325KB) data/lib/mac/x86_64/libpv_cheetah.dylib, (ELF lib, 335KB) libpv_cheetah.so, (ELF lib, 335KB) libpv_cheetah.so and 4 more.

Cheetah Binding for Rust

Cheetah Speech-to-Text Engine

Made in Vancouver, Canada by Picovoice

Cheetah is an on-device streaming speech-to-text engine. Cheetah is:

  • Private; All voice processing runs locally.
  • Accurate
  • Compact and Computationally-Efficient
  • Cross-Platform:
    • Linux (x86_64), macOS (x86_64, arm64), and Windows (x86_64)
    • Android and iOS
    • Chrome, Safari, Firefox, and Edge
    • Raspberry Pi (3, 4, 5)

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 cheetah library into your app, add pv_cheetah to your apps Cargo.toml manifest:

[dependencies]
pv_cheetah = "*"

If you prefer to clone the repo and use it locally, first run copy.sh. (NOTE: on Windows, Git Bash or another bash shell is required, or you will have to manually copy the libs into the project). Then you can reference the local binding location:

[dependencies]
pv_cheetah = { path = "/path/to/rust/binding" }

AccessKey

Cheetah requires a valid Picovoice AccessKey at initialization. AccessKey acts as your credentials when using Cheetah 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 and transcribe audio:

use cheetah::CheetahBuilder;

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

let access_key = "${ACCESS_KEY}"; // AccessKey obtained from Picovoice Console (https://console.picovoice.ai/)
let cheetah: Cheetah = CheetahBuilder::new().access_key(access_key).init().expect("Unable to create Cheetah");

if let Ok(cheetahTranscript) = cheetah.process(&next_audio_frame()) {
  println!("{}", cheetahTranscript.transcript)
  if cheetahTranscript.is_endpoint {
    if let Ok(cheetahTranscript) = cheetah.flush() {
      println!("{}", cheetahTranscript.transcript)
    }
  }
}

Replace ${ACCESS_KEY} with yours obtained from Picovoice Console.

The model file contains the parameters for the Cheetah engine. You may create bespoke language models using Picovoice Console and then pass in the relevant file.

Language Model

The Cheetah Rust SDK comes preloaded with a default English language model (.pv file). Default models for other supported languages can be found in lib/common.

Create custom language models using the Picovoice Console. Here you can train language models with custom vocabulary and boost words in the existing vocabulary.

Pass in the .pv file via the .model_path() Builder argument:

let leopard: Cheetah = CheetahBuilder::new()
    .access_key("${ACCESS_KEY}")
    .model_path("${MODEL_FILE_PATH}")
    .init()
    .expect("Unable to create Cheetah");

Demos

The Cheetah Rust demo project is a Rust console app that allows for processing real-time audio (i.e. microphone) and files using Cheetah.

Dependencies