Porcupine Wake Word
Python API
API Reference for the Python Porcupine SDK (PyPI).
pvporcupine.create()
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 fromkeywords
argument.keywords
Optional[List[str]] : List of built-in keywords (phrases) for detection. Ifkeyword_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
pvporcupine.Porcupine
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
The version string of the Porcupine library.
pvporcupine.Porcupine.frame_length
The number of audio samples per frame that Porcupine accepts.
pvporcupine.Porcupine.sample_rate
The audio sample rate the Porcupine accepts.
pvporcupine.Porcupine.__init__()
__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
pvporcupine.Porcupine.delete()
Releases resources acquired by Porcupine
pvporcupine.Porcupine.process()
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
pvporcupine.PorcupineError
Error thrown if an error occurs within Porcupine
Wake Word engine.
Exceptions