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

Porcupine Wake Word
Rust API

Rust SDKs will no longer be maintained after July 15, 2025. If you plan to use the Porcupine Wake Word Rust SDK for commercial purposes, please contact us.

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


porcupine::BuiltInKeywords

pub enum BuiltinKeywords {
Alexa,
Americano,
Blueberry,
Bumblebee,
Computer,
Grapefruit,
Grasshopper,
HeyGoogle,
HeySiri,
Jarvis,
OkGoogle,
Picovoice,
Porcupine,
Terminator,
}

List of available built-in wake words.


porcupine::Porcupine

pub struct Porcupine

Struct for the Porcupine Wake Word engine.


porcupine::Porcupine.frame_length()

pub fn frame_length(&self) -> u32

Number of audio samples per frame.

Returns

  • u32 : Frame length required by the engine.

porcupine::Porcupine.sample_rate()

pub fn sample_rate(&self) -> u32

Audio sample rate accepted by Porcupine.

Returns

  • u32 : Sample rate required by the engine.

porcupine::Porcupine.version()

pub fn version(&self) -> String

Porcupine version.

Returns

  • String : Version string.

porcupine::Porcupine.process()

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

Processes a frame of the incoming audio stream and emits the detection result. Frame of audio The number of samples-per-frame can be obtained by calling .frame_length. The incoming audio needs to have a sample rate equal to .sample_rate and be 16-bit linearly-encoded. Porcupine operates on single-channel audio. Returns a 0 based index if keyword was detected in frame. Returns -1 if no detection was made.

Parameters

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

Returns

  • Result<i32, PorcupineError> : If Ok, Index of observed keyword at the end of the current frame. Indexing is 0-based and matches the ordering of keywords provided to the Porcupine struct. If no keyword is detected then it returns -1. If Err, a PorcupineError.

porcupine::PorcupineBuilder

pub struct PorcupineBuilder

Builder class for creating an instance of Porcupine with a variety of properties.


porcupine::PorcupineBuilder::new_with_keywords()

pub fn new_with_keywords<S: Into<String>>(
access_key: S,
keywords: &[BuiltinKeywords]
) -> Self

Creates a PorcupineBuilder from built-in keywords.

Parameters

  • access_key S : AccessKey obtained from Picovoice Console.
  • keywords &[BuiltinKeywords] : Built-in keywords to detect.

Returns

  • PorcupineBuilder : A new Builder object.

porcupine::PorcupineBuilder::new_with_keyword_paths()

pub fn new_with_keyword_paths<S: Into<String>, P: Into<PathBuf> + AsRef<OsStr>>(
access_key: S,
keyword_paths: &[P]
) -> Self

Creates a PorcupineBuilder from Porcupine keyword files.

Parameters

  • access_key S : AccessKey obtained from Picovoice Console.
  • keyword_paths &[P] : Paths to Porcupine keyword files (.ppn).

Returns

  • PorcupineBuilder : A new Builder object.

porcupine::PorcupineBuilder.access_key()

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

Modifies the access_key of a PorcupineBuilder object.

Parameters

  • access_key S : AccessKey obtained from Picovoice Console.

Returns

  • PorcupineBuilder : The modified Builder object.

porcupine::PorcupineBuilder.library_path()

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

Overrides the default library_path of a PorcupineBuilder object.

Parameters

  • library_path P : Path to the Porcupine library file.

Returns

  • PorcupineBuilder : The modified Builder object.

porcupine::PorcupineBuilder.model_path()

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

Overrides the default model_path of a PorcupineBuilder object.

Parameters

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

Returns

  • PorcupineBuilder : The modified Builder object.

porcupine::PorcupineBuilder.keyword_paths()

pub fn keyword_paths<'a, P: Into<PathBuf> + AsRef<OsStr>>(
&'a mut self,
keyword_paths: &[P]
) -> &'a mut Self

Modifies the keyword_paths of a PorcupineBuilder object.

Parameters

  • keyword_paths &[P] : Paths to Porcupine keyword files (.ppn).

Returns

  • PorcupineBuilder : The modified Builder object.

porcupine::PorcupineBuilder.sensitivities()

pub fn sensitivities<'a>(&'a mut self, sensitivities: &[f32]) -> &'a mut PorcupineBuilder

Overrides the default sensitivities of a PorcupineBuilder object. Each value should be a number within [0, 1]. A higher sensitivity results in fewer misses at the cost of increasing the false alarm rate. This should be the same size as the number of keywords. If not set, values of 0.5 are used.

Parameters

  • sensitivities &[f32] : Sensitivities for detecting keywords.

Returns

  • PorcupineBuilder : The modified Builder object.

porcupine::PorcupineBuilder.init()

pub fn init(&self) -> Result<Porcupine, PorcupineError>

Creates an instance of Porcupine from the PorcupineBuilder object.

Returns

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

porcupine::PorcupineError

pub struct PorcupineError

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


porcupine::PorcupineError.status

pub status: PorcupineErrorStatus

Type of error encountered.


porcupine::PorcupineError.message

pub status: Option<String>

Message detailing the cause of the error.


porcupine::PorcupineError::new()

pub fn new(status: PorcupineErrorStatus, message: &str) -> Self

Creates a new instance of PorcupineError.

Parameters

  • status PorcupineErrorStatus : Type of error encountered.
  • message &str : Message detailing the cause of the error.

porcupine::PorcupineErrorStatus

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

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


porcupine::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 Porcupine library.

Was this doc helpful?

Issue with this doc?

Report a GitHub Issue
Porcupine Wake Word Rust API
  • porcupine::BuiltInKeywords
  • porcupine::Porcupine
  • frame_length()
  • sample_rate()
  • version()
  • process()
  • porcupine::PorcupineBuilder
  • porcupine::PorcupineBuilder::new_with_keywords()
  • porcupine::PorcupineBuilder::new_with_keyword_paths()
  • access_key()
  • library_path()
  • model_path()
  • keyword_paths()
  • sensitivities()
  • init()
  • porcupine::PorcupineError
  • status
  • message
  • porcupine::PorcupineError::new()
  • porcupine::PorcupineErrorStatus
  • porcupine::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.