Picovoice Wordmark
Start Building
Introduction
Introduction
AndroidC.NETiOSLinuxmacOSNode.jsPythonRaspberry PiWebWindows
AndroidC.NETiOSNode.jsPythonWeb
SummaryPicovoice picoLLMGPTQ
Introduction
AndroidC.NETFlutteriOSJavaLinuxmacOSNode.jsPythonRaspberry PiReactReact NativeRustWebWindows
AndroidC.NETFlutteriOSJavaNode.jsPythonReactReact NativeRustWeb
SummaryPicovoice LeopardAmazon TranscribeAzure Speech-to-TextGoogle ASRGoogle ASR (Enhanced)IBM Watson Speech-to-TextWhisper Speech-to-Text
FAQ
Introduction
AndroidC.NETFlutteriOSJavaLinuxmacOSNode.jsPythonRaspberry PiReactReact NativeRustWebWindows
AndroidC.NETFlutteriOSJavaNode.jsPythonReactReact NativeRustWeb
SummaryPicovoice Cheetah
FAQ
Introduction
AndroidC.NETiOSLinuxmacOSNode.jsPythonRaspberry PiWebWindows
AndroidC.NETiOSNode.jsPythonWeb
SummaryAmazon PollyAzure TTSElevenLabsOpenAI TTSPicovoice Orca
Introduction
AndroidCiOSLinuxmacOSPythonRaspberry PiWebWindows
AndroidCiOSPythonWeb
SummaryPicovoice KoalaMozilla RNNoise
Introduction
AndroidCiOSLinuxmacOSNode.jsPythonRaspberry PiWebWindows
AndroidCNode.jsPythoniOSWeb
SummaryPicovoice EaglepyannoteSpeechBrainWeSpeaker
Introduction
AndroidCiOSLinuxmacOSPythonRaspberry PiWebWindows
AndroidCiOSPythonWeb
SummaryPicovoice FalconAmazon TranscribeAzure Speech-to-TextGoogle Speech-to-Textpyannote
Introduction
AndroidArduinoCChrome.NETEdgeFirefoxFlutteriOSJavaLinuxmacOSMicrocontrollerNode.jsPythonRaspberry PiReactReact NativeRustSafariUnityWebWindows
AndroidC.NETFlutteriOSJavaMicrocontrollerNode.jsPythonReactReact NativeRustUnityWeb
SummaryPorcupineSnowboyPocketSphinx
Wake Word TipsFAQ
Introduction
AndroidCChrome.NETEdgeFirefoxFlutteriOSJavaLinuxmacOSNode.jsPythonRaspberry PiReactReact NativeRustSafariUnityWebWindows
AndroidC.NETFlutteriOSJavaNode.jsPythonReactReact NativeRustUnityWeb
SummaryPicovoice RhinoGoogle DialogflowAmazon LexIBM WatsonMicrosoft LUIS
Expression SyntaxFAQ
Introduction
AndroidC.NETiOSLinuxmacOSNode.jsPythonRaspberry PiRustWebWindows
AndroidC.NETiOSNode.jsPythonRustWeb
SummaryPicovoice CobraWebRTC VAD
FAQ
Introduction
AndroidC.NETFlutteriOSNode.jsPythonReact NativeRustUnityWeb
AndroidC.NETFlutteriOSNode.jsPythonReact NativeRustUnityWeb
Introduction
C.NETNode.jsPython
C.NETNode.jsPython
FAQGlossary

Leopard Speech-to-Text
Rust API

Rust SDKs will no longer be maintained after July 15, 2025. If you plan to use the Leopard Speech-to-Text Rust SDK for commercial purposes, please contact us.

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


leopard::Leopard

pub struct Leopard

Struct for the Leopard Speech-to-Text engine.


leopard::Leopard.process()

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

Processes a given audio data and returns its transcription. The audio needs to have a sample rate equal to .sample_rate and be 16-bit linearly-encoded. This function operates on single-channel audio. If you wish to process data in a different sample rate or format consider using .process_file().

Parameters

  • pcm &[i16] : Audio data.

Returns

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

leopard::Leopard.process_file()

pub fn process_file<P: AsRef<Path>>(&self, audio_path: P) -> Result<LeopardTranscript, LeopardError>

Processes a given audio file and returns its transcription. The supported audio file formats are: 3gp (AMR), FLAC, MP3, MP4/m4a (AAC), Ogg, WAV and WebM.

Parameters

  • audio_path P : Absolute path to the audio file.

Returns

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

leopard::Leopard.sample_rate()

pub fn sample_rate(&self) -> u32

Gets the sample rate.

Returns

  • u32 : Audio sample rate accepted by Leopard.

leopard::Leopard.version()

pub fn version(&self) -> &str

Gets the Leopard version.

Returns

  • &str : Leopard version string.

leopard::LeopardBuilder

pub struct LeopardBuilder

Builder struct for creating an instance of Leopard.


leopard::LeopardBuilder.new()

pub fn new()) -> Self

Creates a new LeopardBuilder.

Returns

  • LeopardBuilder : A new Builder object.

leopard::LeopardBuilder.access_key()

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

Modifies the access_key of a LeopardBuilder object.

Parameters

  • access_key S : AccessKey obtained from Picovoice Console.

Returns

  • LeopardBuilder : The modified Builder object.

leopard::LeopardBuilder.model_path()

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

Modifies the model_path of a LeopardBuilder object.

Parameters

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

Returns

  • LeopardBuilder : The modified Builder object.

leopard::LeopardBuilder.library_path()

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

Modifies the library_path of a LeopardBuilder object.

Parameters

  • library_path P : Path to the Leopard library file.

Returns

  • LeopardBuilder : The modified Builder object.

leopard::LeopardBuilder.enable_automatic_punctuation()

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

Modifies the enable_automatic_punctuation of a LeopardBuilder object.

Parameters

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

Returns

  • LeopardBuilder : The modified Builder object.

leopard::LeopardBuilder.enable_diarization()

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

Modifies the enable_diarization of a LeopardBuilder object.

Parameters

  • enable_automatic_punctuation bool : Set to true to enable speaker diarization, which allows Leopard to differentiate speakers as part of the transcription process. Word metadata will include a speakerTag to identify unique speakers.

Returns

  • LeopardBuilder : The modified Builder object.

leopard::LeopardBuilder.init()

pub fn init(&self) -> Result<Leopard, LeopardError>

Creates an instance of Leopard from the LeopardBuilder object.

Returns

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

leopard::LeopardWord

#[derive(PartialEq, Clone, Debug)]
pub struct LeopardWord {
pub word: String,
pub start_sec: f32,
pub end_sec: f32,
pub confidence: f32,
pub speaker_tag: i32,
}

Struct containing a transcribed word and associated word metadata.

  • word String : Transcribed word.
  • start_sec f32 : Start of word in seconds.
  • end_sec f32 : End of word in seconds.
  • confidence f32 : Transcription confidence. It is a number within [0, 1].
  • speaker_tag i32 : The speaker tag is -1 if diarization is not enabled during initialization; otherwise, it's a non-negative integer identifying unique speakers, with 0 reserved for unknown speakers.

leopard::LeopardTranscript

#[derive(PartialEq, Clone, Debug)]
pub struct LeopardTranscript {
pub transcript: String,
pub words: Vec<LeopardWord>,
}

Struct containing a transcript and transcribed words from Leopard.


leopard::LeopardError

pub struct LeopardError

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


leopard::LeopardError.new()

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

Creates a new instance of LeopardError

Parameters

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

leopard::LeopardErrorStatus

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

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


leopard::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 Leopard library.

Was this doc helpful?

Issue with this doc?

Report a GitHub Issue
Leopard Speech-to-Text Rust API
  • leopard::Leopard
  • process()
  • process_file()
  • sample_rate()
  • version()
  • leopard::LeopardBuilder
  • new()
  • access_key()
  • model_path()
  • library_path()
  • enable_automatic_punctuation()
  • enable_diarization()
  • init()
  • leopard::LeopardWord
  • leopard::LeopardTranscript
  • leopard::LeopardError
  • new()
  • leopard::LeopardErrorStatus
  • leopard::PvStatus
Voice AI
  • Leopard Speech-to-Text
  • Cheetah Streaming Speech-to-Text
  • Orca Text-to-Speech
  • Koala Noise Suppression
  • Eagle Speaker Recognition
  • Falcon Speaker Diarization
  • Porcupine Wake Word
  • Rhino Speech-to-Intent
  • Cobra Voice Activity Detection
Local LLM
  • picoLLM Inference
  • picoLLM Compression
  • picoLLM GYM
Resources
  • Docs
  • Console
  • Blog
  • Use Cases
  • Playground
Sales & Services
  • Consulting
  • Foundation Plan
  • Enterprise Plan
  • Enterprise Support
Company
  • About us
  • Careers
Follow Picovoice
  • LinkedIn
  • GitHub
  • X
  • YouTube
  • AngelList
Subscribe to our newsletter
Terms of Use
Privacy Policy
© 2019-2025 Picovoice Inc.