Picovoice Wordmark
Start Building
Introduction
Introduction
AndroidC.NETFlutterlink to GoiOSJavaNVIDIA JetsonLinuxmacOSNodejsPythonRaspberry PiReact NativeRustWebWindows
AndroidC.NETFlutterlink to GoiOSJavaNodejsPythonReact NativeRustWeb
SummaryPicovoice LeopardAmazon TranscribeAzure Speech-to-TextGoogle ASRGoogle ASR (Enhanced)IBM Watson Speech-to-Text
FAQ
Introduction
AndroidC.NETFlutterlink to GoiOSJavaNVIDIA JetsonLinuxmacOSNodejsPythonRaspberry PiReact NativeRustWebWindows
AndroidC.NETFlutterlink to GoiOSJavaNodejsPythonReact NativeRustWeb
FAQ
Introduction
AndroidCiOSLinuxmacOSPythonWebWindows
AndroidCiOSPythonWeb
SummaryOctopus Speech-to-IndexGoogle Speech-to-TextMozilla DeepSpeech
FAQ
Introduction
AndroidAngularArduinoBeagleBoneCChrome.NETEdgeFirefoxFlutterlink to GoiOSJavaNVIDIA JetsonLinuxmacOSMicrocontrollerNodejsPythonRaspberry PiReactReact NativeRustSafariUnityVueWebWindows
AndroidAngularC.NETFlutterlink to GoiOSJavaMicrocontrollerNodejsPythonReactReact NativeRustUnityVueWeb
SummaryPorcupineSnowboyPocketSphinx
Wake Word TipsFAQ
Introduction
AndroidAngularBeagleBoneCChrome.NETEdgeFirefoxFlutterlink to GoiOSJavaNVIDIA JetsonLinuxmacOSNodejsPythonRaspberry PiReactReact NativeRustSafariUnityVueWebWindows
AndroidAngularC.NETFlutterlink to GoiOSJavaNodejsPythonReactReact NativeRustUnityVueWeb
SummaryPicovoice RhinoGoogle DialogflowAmazon LexIBM WatsonMicrosoft LUIS
Expression SyntaxFAQ
Introduction
AndroidBeagleboneCiOSNVIDIA JetsonLinuxmacOSPythonRaspberry PiRustWebWindows
AndroidCiOSPythonRustWeb
SummaryPicovoice CobraWebRTC VAD
FAQ
Introduction
AndroidCiOSNVIDIA JetsonLinuxmacOSPythonRaspberry PiWebWindows
AndroidCiOSPythonWeb
SummaryPicovoice KoalaMozilla RNNoise
Introduction
AndroidCiOSNVIDIA JetsonLinuxmacOSPythonRaspberry PiWebWindows
AndroidCPythoniOSWeb
Introduction
AndroidAngularArduinoBeagleBoneC.NETFlutterlink to GoiOSJavaNVIDIA JetsonMicrocontrollerNodejsPythonRaspberry PiReactReact NativeRustUnityVueWeb
AndroidAngularCMicrocontroller.NETFlutterlink to GoiOSJavaNodejsPythonReactReact NativeRustUnityVueWeb
Picovoice SDK - FAQ
IntroductionSTM32F407G-DISC1 (Arm Cortex-M4)STM32F411E-DISCO (Arm Cortex-M4)STM32F769I-DISCO (Arm Cortex-M7)IMXRT1050-EVKB (Arm Cortex-M7)
Introduction
AndroidC.NETFlutterlink to GoiOSNodejsPythonReact NativeRustUnityWeb
AndroidC.NETFlutterlink to GoiOSNodejsPythonReact NativeRustUnityWeb
FAQGlossary

Cheetah Speech-to-Text
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() -> Self

Creates a new CheetahBuilder.

Returns

  • CheetahBuilder : A new Builder object.

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

  • access_key S : AccessKey obtained from Picovoice Console .

Returns

  • CheetahBuilder : The modified Builder object.

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

  • CheetahBuilder : The modified Builder object.

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

  • CheetahBuilder : The modified Builder object.

cheetah::CheetahBuilder.endpoint_duration_sec()

pub fn endpoint_duration_sec(&mut self, endpoint_duration_sec: f32) -> &mut Self

Modifies the endpoint_duration_sec of a CheetahBuilder object.

Parameters

  • endpoint_duration_sec f32 : Duration of endpoint in seconds. A speech endpoint is detected when there is a segment of audio (with a duration specified herein) after an utterance without any speech in it. Set to 0 to disable endpoint detection.

Returns

  • CheetahBuilder : The modified Builder object.

cheetah::CheetahBuilder.enable_automatic_punctuation()

pub fn enable_automatic_punctuation(&mut self, enable_automatic_punctuation: bool) -> &mut Self

Modifies the enable_automatic_punctuation of a CheetahBuilder object.

Parameters

  • enable_automatic_punctuation bool : Set to true to enable automatic punctuation insertion.

Returns

  • CheetahBuilder : The modified Builder object.

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.

Was this doc helpful?

Issue with this doc?

Report a GitHub Issue
Cheetah Speech-to-Text Rust API
  • cheetah::Cheetah
  • process()
  • flush()
  • frame_length()
  • sample_rate()
  • version()
  • cheetah::CheetahBuilder
  • new()
  • access_key()
  • model_path()
  • library_path()
  • endpoint_duration_sec()
  • enable_automatic_punctuation()
  • init()
  • cheetah::CheetahTranscript
  • cheetah::CheetahError
  • new()
  • cheetah::CheetahErrorStatus
  • cheetah::PvStatus
Platform
  • Leopard Speech-to-Text
  • Cheetah Streaming Speech-to-Text
  • Koala Noise Suppression
  • Eagle Speaker RecognitionBETA
  • Octopus Speech-to-Index
  • Porcupine Wake Word
  • Rhino Speech-to-Intent
  • Cobra Voice Activity Detection
  • Orca Text-to-SpeechWAITLIST
  • Falcon Speaker DiarizationWAITLIST
Resources
  • Docs
  • Console
  • Blog
  • Use Cases
Sales & Services
  • Consulting
  • Developer Plan
  • Enterprise Plan
  • Support Add-on
Company
  • About us
  • Careers
Follow Picovoice
  • LinkedIn
  • GitHub
  • Twitter
  • Medium
  • YouTube
  • AngelList
Subscribe to our newsletter
Terms of Use
Privacy Policy
© 2019-2022 Picovoice Inc.