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

Picovoice Platform — Python API


API Reference for the Python Picovoice SDK (PyPI).


picovoice.Picovoice

class Picovoice(object)

Class for the Picovoice SDK. Picovoice can be initialized using the class __init__() method. Resources should be cleaned when you are done using the delete() method.


picovoice.Picovoice.context_info

self.context_info: str

The context information of the Picovoice instance.


picovoice.Picovoice.version

self.version: str

The version string of the Picovoice library.


picovoice.Picovoice.frame_length

self.frame_length: int

The number of audio samples per frame that Picovoice accepts.


picovoice.Picovoice.sample_rate

self.sample_rate: int

The audio sample rate the Picovoice accepts.


picovoice.Picovoice.__init__()

def __init__(
self,
access_key: str,
keyword_path: str,
wake_word_callback: Callable[None, None],
context_path: str,
inference_callback: Callable[[pvrhino.Rhino.Inference], None],
porcupine_library_path: Optional[str] = None,
porcupine_model_path: Optional[str] = None,
porcupine_sensitivity: Optional[float] = 0.5,
rhino_library_path: Optional[str] = None,
rhino_model_path: Optional[str] = None,
rhino_sensitivity: Optional[float] = 0.5,
endpoint_duration_sec: Optional[float] = 1.,
require_endpoint: Optional[bool] = True) -> Picovoice

__init__ method for Picovoice SDK.

Parameters

  • access_key str : AccessKey obtained from Picovoice Console.
  • keyword_path str : Absolute path to Porcupine keyword file (.ppn).
  • wake_word_callback Callable[None, None] : Function to be called once the wake word has been detected.
  • context_path str : Absolute path to the Rhino context file (.rhn).
  • inferenceCallback Callable[[pvrhino.Rhino.Inference], None] : Function to be called once Rhino has an inference ready.
  • porcupine_library_path Optional[str] : Absolute path to Porcupine's dynamic library. If not set it will be set to the default location.
  • porcupine_model_path Optional[str] : Absolute path to Porcupine model file (.pv). If not set it will be set to the default location.
  • porcupine_sensitivity Optional[str] : Wake word sensitivity. It 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.
  • rhino_library_path Optional[str] : Absolute path to Rhino's dynamic library. If not set it will be set to the default location.
  • rhino_model_path Optional[str] : Absolute path to the file containing model parameters. If not set it will be set to the default location.
  • sensitivity Optional[float] : Inference sensitivity. It should be a number within [0, 1]. A higher sensitivity value results in fewer misses at the cost of (potentially) increasing the erroneous inference rate.
  • endpoint_duration_sec Optional[float] : 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.
  • requireEndpoint Optional[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

  • Picovoice: An instance of Picovoice SDK.

Throws

  • PicovoiceError

picovoice.Picovoice.delete()

def delete(self)

Releases resources acquired by Picovoice.


picovoice.Picovoice.process()

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

Processes a frame of the incoming audio stream. Invokes user-defined callbacks upon detection of wake word and completion of follow-on command inference. 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. Picovoice operates on single-channel audio.

Parameters

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

Throws

  • PicovoiceError

picovoice.PicovoiceError

class PicovoiceError(Exception)

Error thrown if an error occurs within Picovoice engine.

Exceptions

class PicovoiceActivationError(PicovoiceError)
class PicovoiceActivationLimitError(PicovoiceError)
class PicovoiceActivationRefusedError(PicovoiceError)
class PicovoiceActivationThrottledError(PicovoiceError)
class PicovoiceIOError(PicovoiceError)
class PicovoiceInvalidArgumentError(PicovoiceError)
class PicovoiceInvalidStateError(PicovoiceError)
class PicovoiceKeyError(PicovoiceError)
class PicovoiceMemoryError(PicovoiceError)
class PicovoiceRuntimeError(PicovoiceError)
class PicovoiceStopIterationError(PicovoiceError)

Was this doc helpful?

Issue with this doc?

Report a GitHub Issue
Picovoice Platform — Python API
  • picovoice.Picovoice
  • context_info
  • version
  • frame_length
  • sample_rate
  • __init__()
  • delete()
  • process()
  • 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.