rustCheetah - Rust API

API Reference for the Cheetah Rust SDK (crates.io).


cheetah::Cheetah

pub struct Cheetah

Struct for the Cheetah Speech-to-Text engine.


cheetah::Cheetah.process()

pub fn process(&self, pcm: &[i16]) -> Result<CheetahTranscript, CheetahError>

Processes a frame of audio and returns newly-transcribed text and a flag indicating if an endpoint has been detected. Upon detection of an endpoint, the client may invoke .flush() to retrieve any remaining transcription.

The number of samples per frame can be attained by calling .frame_length. The incoming audio needs to have a sample rate equal to .sample_rate and be 16-bit linearly-encoded. Furthermore, Cheetah operates on single-channel audio.

Parameters

  • pcm &[i16] : Audio data.

Returns

  • Result<CheetahTranscript, CheetahError> : If Ok, returns the inferred transcription as a CheetahTranscript object. If Err, a CheetahError object describing the error that was encountered.

cheetah::Cheetah.flush()

pub fn flush(&self) -> Result<CheetahTranscript, CheetahError>

Marks the end of the audio stream, flushes internal state of the object, and returns any remaining transcribed text.

Returns

  • Result<CheetahTranscript, CheetahError> : If Ok, returns the remaining inferred transcription as a CheetahTranscript object. If Err, a CheetahError object describing the error that was encountered.

cheetah::Cheetah.frame_length()

pub fn frame_length(&self) -> u32

Gets the frame length.

Returns

  • u32 : Audio frame length accepted by Cheetah.

cheetah::Cheetah.sample_rate()

pub fn sample_rate(&self) -> u32

Gets the sample rate.

Returns

  • u32 : Audio sample rate accepted by Cheetah.

cheetah::Cheetah.version()

pub fn version(&self) -> &str

Gets the Cheetah version.

Returns

  • &str : Cheetah version string.

cheetah::CheetahBuilder

pub struct CheetahBuilder

Builder struct for creating an instance of Cheetah.


cheetah::CheetahBuilder.new()

pub fn new<S: Into<String>>(access_key: S) -> Self

Creates a new CheetahBuilder from required arguments.

Parameters

Returns


cheetah::CheetahBuilder.access_key()

pub fn access_key<S: Into<String>>(&mut self, access_key: S) -> &mut Self

Modifies the access_key of a CheetahBuilder object.

Parameters

Returns


cheetah::CheetahBuilder.library_path()

pub fn library_path<P: Into<PathBuf>>(&mut self, library_path: P) -> &mut Self

Modifies the library_path of a CheetahBuilder object.

Parameters

  • library_path P : Path to the Cheetah library file.

Returns


cheetah::CheetahBuilder.model_path()

pub fn model_path<P: Into<PathBuf>>(&mut self, model_path: P) -> &mut Self

Modifies the model_path of a CheetahBuilder object.

Parameters

  • model_path P : Path to the file containing model parameters (.pv).

Returns


cheetah::CheetahBuilder.init()

pub fn init(&self) -> Result<Cheetah, CheetahError>

Creates an instance of Cheetah from the CheetahBuilder object.

Returns

  • Result<Cheetah, CheetahError> : If Ok, an initialized instance of Cheetah. If Err, an instance of CheetahError detailing the error that was encountered.

cheetah::CheetahTranscript

pub struct CheetahTranscript {
pub transcript: String,
pub is_endpoint: bool,
}

Struct containing transcript information returned by the Cheetah Rust SDK.

Properties

  • transcript String : Any transcribed speech (if none, then an empty string is returned).
  • is_endpoint bool : A flag indicating if an endpoint has been detected.

cheetah::CheetahError

pub struct CheetahError

An error type describing any errors encountered by the Cheetah SDK.


cheetah::CheetahError.new()

pub fn new(status: CheetahErrorStatus, message: impl Into<String>) -> Self

Creates a new instance of CheetahError

Parameters

  • status CheetahErrorStatus : Type of error encountered.
  • message impl Into<String> : Message detailing the cause of the error.

cheetah::CheetahErrorStatus

pub enum CheetahErrorStatus {
LibraryError(PvStatus),
LibraryLoadError,
FrameLengthError,
ArgumentError,
}

Enum describing possible error types returned from the Cheetah Rust SDK.


cheetah::PvStatus

pub enum PvStatus {
SUCCESS,
OUT_OF_MEMORY,
IO_ERROR,
INVALID_ARGUMENT,
STOP_ITERATION,
KEY_ERROR,
INVALID_STATE,
RUNTIME_ERROR,
ACTIVATION_ERROR,
ACTIVATION_LIMIT_REACHED,
ACTIVATION_THROTTLED,
ACTIVATION_REFUSED,
}

Error codes returned from the Cheetah library.


Issue with this doc? Please let us know.