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
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

Porcupine Wake Word — Python API


API Reference for the Python Porcupine SDK (PyPI).


pvporcupine.create()

def create(
access_key: str,
library_path: Optional[str] = None,
model_path: Optional[str] = None,
keyword_paths: Optional[List[str]] = None,
keywords: Optional[List[str]] = None,
sensitivities: Optional[List[float]] = None) -> Porcupine

Factory method for Porcupine Wake Word engine.

Parameters

  • access_key str : AccessKey obtained from Picovoice Console.
  • library_path Optional[str] : Absolute path to Porcupine's dynamic library. If not set it will be set to the default location.
  • model_path Optional[str] : Absolute path to the file containing model parameters. If not set it will be set to the default location.
  • keyword_paths Optional[List[str]] : Absolute paths to keyword model files. If not set it will be populated from keywords argument.
  • keywords Optional[List[str]] : List of built-in keywords (phrases) for detection. If keyword_paths is set then this argument will be ignored.
  • sensitivities Optional[List[float]] : Sensitivities for detecting keywords. 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. If not set 0.5 will be used.

Returns

  • Porcupine: An instance of Porcupine Wake Word engine.

Throws

  • PorcupineError

pvporcupine.Porcupine

class Porcupine(object)

Class for the Porcupine Wake Word engine. Porcupine can be initialized either using the module level create() function or directly using the class __init__() method. Resources should be cleaned when you are done using the delete() method.


pvporcupine.Porcupine.version

self.version: str

The version string of the Porcupine library.


pvporcupine.Porcupine.frame_length

self.frame_length: int

The number of audio samples per frame that Porcupine accepts.


pvporcupine.Porcupine.sample_rate

self.sample_rate: int

The audio sample rate the Porcupine accepts.


pvporcupine.Porcupine.__init__()

def __init__(
self,
access_key: str,
library_path: str,
model_path: str,
keyword_paths: List[str],
sensitivities: List[float]) -> Porcupine

__init__ method for Porcupine Wake Word engine.

Parameters

  • access_key str : AccessKey obtained from Picovoice Console.
  • library_path str : Absolute path to Porcupine's dynamic library.
  • model_path str : Absolute path to the file containing model parameters.
  • keyword_paths List[str] : Absolute paths to keyword model files.
  • sensitivities List[float] : Sensitivities for detecting keywords. 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.

Returns

  • Porcupine: An instance of Porcupine Wake Word engine.

Throws

  • PorcupineError

pvporcupine.Porcupine.delete()

def delete(self)

Releases resources acquired by Porcupine


pvporcupine.Porcupine.process()

def process(self, pcm: List[int]) -> int

Processes a frame of the incoming audio stream and emits the detection result. 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. Porcupine operates on single-channel audio.

Parameters

  • pcm List[int] : A frame of audio samples.

Returns

  • int : Index of observed keyword at the end of the current frame. Indexing is 0-based and matches the ordering of keyword models provided to the constructor. If no keyword is detected then it returns -1.

Throws

  • PorcupineError

pvporcupine.PorcupineError

class PorcupineError(Exception)

Error thrown if an error occurs within Porcupine Wake Word engine.

Exceptions

class PorcupineActivationError(PorcupineError)
class PorcupineActivationLimitError(PorcupineError)
class PorcupineActivationRefusedError(PorcupineError)
class PorcupineActivationThrottledError(PorcupineError)
class PorcupineIOError(PorcupineError)
class PorcupineInvalidArgumentError(PorcupineError)
class PorcupineInvalidStateError(PorcupineError)
class PorcupineKeyError(PorcupineError)
class PorcupineMemoryError(PorcupineError)
class PorcupineRuntimeError(PorcupineError)
class PorcupineStopIterationError(PorcupineError)

Was this doc helpful?

Issue with this doc?

Report a GitHub Issue
Porcupine Wake Word — Python API
  • pvporcupine.create()
  • pvporcupine.Porcupine
  • version
  • frame_length
  • sample_rate
  • __init__()
  • delete()
  • process()
  • pvporcupine.PorcupineError
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.