#specch-to-text

pv_cheetah

The Rust bindings for Picovoice’s Cheetah library

2 stable releases

new 1.0.1 May 12, 2022
1.0.0 Mar 21, 2022
0.9.0 Mar 19, 2022

#144 in Machine learning

49 downloads per month

Apache-2.0

17MB
477 lines

Cheetah Binding for Rust

Cheetah Speech-to-Text Engine

Made in Vancouver, Canada by Picovoice

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

  • Private; All voice processing runs locally.
  • Accurate [1]
  • Compact and Computationally-Efficient [2]
  • Cross-Platform:
    • Linux (x86_64)
    • macOS (x86_64, arm64)
    • Windows (x86_64)
    • Android
    • iOS
    • Raspberry Pi (4, 3)
    • NVIDIA Jetson Nano

Compatibility

  • Rust 1.54+
  • Runs on Linux (x86_64), macOS (x86_64, arm64), Windows (x86_64), Raspberry Pi (4, 3), and NVIDIA Jetson Nano.

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).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.

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