Picovoice WordmarkPicovoice Console
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 GoiOSJavaNodejsPythonReact NativeRustWeb
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
AndroidCiOSPythonWeb
AndroidCiOSPythonWeb
SummaryPicovoice KoalaMozilla RNNoise
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)
FAQGlossary

Picovoice Platform — Rust API


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


picovoice::Picovoice

pub struct Picovoice<W, I>
where
W: FnMut(),
I: FnMut(RhinoInference),

Struct for the Picovoice Platform.


picovoice::Picovoice::new()

pub fn new<S: Into<String>, P: Into<PathBuf>>(
access_key: S,
keyword_path: P,
wake_word_callback: W,
context_path: P,
inference_callback: I,
porcupine_library_path: Option<P>,
porcupine_model_path: Option<P>,
porcupine_sensitivity: Option<f32>,
rhino_library_path: Option<P>,
rhino_model_path: Option<P>,
rhino_sensitivity: Option<f32>,
rhino_endpoint_duration_sec: Option<f32>,
rhino_require_endpoint: bool
) -> Result<Self, PicovoiceError>

Creates a new instance of Picovoice.

Parameters

  • access_key S : AccessKey obtained from Picovoice Console .
  • keyword_path P : Absolute path to Porcupine keyword file (.ppn).
  • wake_word_callback W : Function to be called once the wake word has been detected.
  • context_path P : Absolute path to the Rhino context file (.rhn).
  • inference_callback I : Function to be called once Rhino has an inference ready.
  • porcupine_library_path Option<P> : Absolute path to the Porcupine library.
  • porcupine_model_path Option<P> : Path to Porcupine model file (.pv).
  • porcupine_sensitivity Option<f32> : Sensitivity value for detecting keyword. The value should be a number within [0, 1]. A higher sensitivity results in fewer misses at the cost of increasing the false alarm rate.
  • rhino_library_path Option<P> : Absolute path to the Rhino library.
  • rhino_model_path Option<P> : Path to Rhino model file (.pv).
  • rhino_sensitivity Option<f32> : Inference sensitivity. A higher sensitivity value results in fewer misses at the cost of (potentially) increasing the erroneous inference rate. Sensitivity should be a floating-point number within 0 and 1.
  • rhino_endpoint_duration_sec Option<f32> : Endpoint duration in seconds. An endpoint is a chunk of silence at the end of an utterance that marks the end of spoken command. It should be a positive number within [0.5, 5]. A lower endpoint duration reduces delay and improves responsiveness. A higher endpoint duration assures Rhino doesn't return inference pre-emptively in case the user pauses before finishing the request.
  • rhino_require_endpoint bool : If set to true, Rhino requires an endpoint (a chunk of silence) after the spoken command. If set to false, Rhino tries to detect silence, but if it cannot, it still will provide inference regardless. Set to false only if operating in an environment with overlapping speech (e.g. people talking in the background).

Returns

  • Result<Picovoice, PicovoiceError> : If Ok, an instance of Picovoice struct. If Err, a PicovoiceError describing the error that was encountered.

picovoice::Picovoice.process()

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

Process a frame of pcm audio with the Picovoice platform. Invokes user-defined callbacks upon detection of wake word and completion of follow-on command inference.

Parameters

  • pcm &[i16] : A frame of audio samples.

Returns

  • Result<(), PicovoiceError> : If Ok, nothing is returned. If Err, a PicovoiceError describing the error that was encountered.

picovoice::Picovoice.frame_length()

pub fn frame_length(&self) -> u32

Gets the required frame length.

Returns

  • u32 : Number of audio samples per frame.

picovoice::Picovoice.sample_rate()

pub fn sample_rate(&self) -> u32

Gets the required sample rate.

Returns

  • u32 : Audio sample rate accepted by Picovoice.

picovoice::Picovoice.version()

pub fn version(&self) -> String

Gets the Picovoice version.

Returns

  • String : Picovoice version string.

picovoice::PicovoiceBuilder

pub struct PicovoiceBuilder<W, I>
where
W: FnMut(),
I: FnMut(RhinoInference),

Builder class for creating an instance of Picovoice.


picovoice::PicovoiceBuilder::new()

pub fn new<S: Into<String>, P: Into<PathBuf>>(
access_key: S,
keyword_path: P,
wake_word_callback: W,
context_path: P,
inference_callback: I
) -> Self

Creates a new instance of PicovoiceBuilder.

Parameters

  • access_key S : AccessKey obtained from Picovoice Console .
  • keyword_path P : Absolute path to Porcupine keyword file (.ppn).
  • wake_word_callback W : Function to be called once the wake word has been detected.
  • context_path P : Absolute path to the Rhino context file (.rhn).
  • inference_callback I : Function to be called once Rhino has an inference ready.

Returns

  • PicovoiceBuilder : A new Builder object.

picovoice::PicovoiceBuilder.porcupine_library_path()

pub fn porcupine_library_path<P: Into<PathBuf>>(
self,
porcupine_library_path: P
) -> Self

Overrides the default porcupine_library_path of a PicovoiceBuilder object.

Parameters

  • porcupine_library_path P : Absolute path to the Porcupine library.

Returns

  • PicovoiceBuilder : The modified Builder object.

picovoice::PicovoiceBuilder.porcupine_model_path()

pub fn porcupine_model_path<P: Into<PathBuf>>(
self,
porcupine_model_path: P
) -> Self

Overrides the default porcupine_model_path of a PicovoiceBuilder object.

Parameters

  • porcupine_model_path P : Path to Porcupine model file (.pv).

Returns

  • PicovoiceBuilder : The modified Builder object.

picovoice::PicovoiceBuilder.porcupine_sensitivity()

pub fn porcupine_sensitivity(self, porcupine_sensitivity: f32) -> Self

Overrides the default porcupine_sensitivity of a PicovoiceBuilder object.

Parameters

  • porcupine_sensitivity f32 : Sensitivity value for detecting keyword. The value should be a number within [0, 1]. A higher sensitivity results in fewer misses at the cost of increasing the false alarm rate.

Returns

  • PicovoiceBuilder : The modified Builder object.

picovoice::PicovoiceBuilder.rhino_library_path()

pub fn rhino_library_path<P: Into<PathBuf>>(self, rhino_library_path: P) -> Self

Overrides the default rhino_library_path of a PicovoiceBuilder object.

Parameters

  • rhino_library_path P : Absolute path to the Rhino library.

Returns

  • PicovoiceBuilder : The modified Builder object.

picovoice::PicovoiceBuilder.rhino_model_path()

pub fn rhino_model_path<P: Into<PathBuf>>(self, rhino_model_path: P) -> Self

Overrides the default rhino_model_path of a PicovoiceBuilder object.

Parameters

  • rhino_model_path P : Path to Rhino model file (.pv).

Returns

  • PicovoiceBuilder : The modified Builder object.

picovoice::PicovoiceBuilder.rhino_sensitivity()

pub fn rhino_sensitivity(self, rhino_sensitivity: f32) -> Self

Overrides the default rhino_sensitivity of a PicovoiceBuilder object.

Parameters

  • rhino_sensitivity f32 : Inference sensitivity. A higher sensitivity value results in fewer misses at the cost of (potentially) increasing the erroneous inference rate. Sensitivity should be a floating-point number within 0 and 1.

Returns

  • PicovoiceBuilder : The modified Builder object.

picovoice::PicovoiceBuilder.rhino_endpoint_duration_sec()

pub fn rhino_endpoint_duration_sec(self, rhino_endpoint_duration_sec: f32) -> Self

Overrides the default rhino_endpoint_duration_sec of a PicovoiceBuilder object.

Parameters

  • rhino_endpoint_duration_sec f32 : Endpoint duration in seconds. An endpoint is a chunk of silence at the end of an utterance that marks the end of spoken command. It should be a positive number within [0.5, 5]. A lower endpoint duration reduces delay and improves responsiveness. A higher endpoint duration assures Rhino doesn't return inference pre-emptively in case the user pauses before finishing the request.

Returns

  • PicovoiceBuilder : The modified Builder object.

picovoice::PicovoiceBuilder.rhino_require_endpoint()

pub fn rhino_require_endpoint(self, rhino_require_endpoint: bool) -> Self

Overrides the default value of rhino_require_endpoint in a PicovoiceBuilder object.

Parameters

  • rhino_require_endpoint bool : If set to true, Rhino requires an endpoint (a chunk of silence) after the spoken command. If set to false, Rhino tries to detect silence, but if it cannot, it still will provide inference regardless. Set to false only if operating in an environment with overlapping speech (e.g. people talking in the background).

Returns

  • PicovoiceBuilder : The modified Builder object.

picovoice::PicovoiceBuilder.init()

pub fn init(self) -> Result<Picovoice<W, I>, PicovoiceError>

Creates an instance of Picovoice from the PicovoiceBuilder object.

Returns

  • Result<Picovoice<W, I>, PicovoiceError> : If Ok, an initialized instance of Picovoice. If Err, and instance of PicovoiceError detailing the error that was encountered.

picovoice::PicovoiceError

pub enum PicovoiceError {
RhinoError(RhinoError),
PorcupineError(PorcupineError),
LibraryError(String),
}

An error type describing errors produced by the Picovoice Rust SDK.

Was this doc helpful?

Issue with this doc?

Report a GitHub Issue
Picovoice Platform — Rust API
  • picovoice::Picovoice
  • picovoice::Picovoice::new()
  • process()
  • frame_length()
  • sample_rate()
  • version()
  • picovoice::PicovoiceBuilder
  • picovoice::PicovoiceBuilder::new()
  • porcupine_library_path()
  • porcupine_model_path()
  • porcupine_sensitivity()
  • rhino_library_path()
  • rhino_model_path()
  • rhino_sensitivity()
  • rhino_endpoint_duration_sec()
  • rhino_require_endpoint()
  • init()
  • picovoice::PicovoiceError
Platform
  • Leopard Speech-to-Text
  • Cheetah Streaming Speech-to-Text
  • Octopus Speech-to-Index
  • Porcupine Wake Word
  • Rhino Speech-to-Intent
  • Cobra Voice Activity Detection
Resources
  • Docs
  • Console
  • Blog
  • Demos
Sales
  • Pricing
  • Starter Tier
  • Enterprise
Company
  • Careers
Follow Picovoice
  • LinkedIn
  • GitHub
  • Twitter
  • Medium
  • YouTube
  • AngelList
Subscribe to our newsletter
Terms of Use
Privacy Policy
© 2019-2022 Picovoice Inc.