Porcupine Wake Word
React Native API
API Reference for the React Native Porcupine SDK (npm)
Porcupine
Class for the Porcupine Wake Word engine.
Porcupine.fromBuiltInKeywords()
Porcupine
constructor when using built-in keywords.
Parameters
accessKey
string : AccessKey obtained from Picovoice Console.keywords
BuiltInKeyword[] : List of built-in keywords for detection.modelPath
string : Optional. Path to the file containing model parameters (.pv
). Can be relative to the assets/resource folder or an absolute path to the file on device.sensitivities
number[] : Optional. Sensitivities for detecting keywords. Each value should be a number within [0, 1].
Returns
Promise<Porcupine>
: An instance of Porcupine Wake Word engine.
Porcupine.fromKeywordPaths()
Porcupine
constructor when using keyword paths.
Parameters
accessKey
string : AccessKey obtained from Picovoice Console.keywordPaths
string[] : List of paths to keyword files (.ppn
). Can be relative to the assets/resource folder or absolute paths to the files on device.modelPath
string : Optional. Absolute path to the file containing model parameters (.pv
). Can be relative to the assets/resource folder or an absolute path to the file on device.sensitivities
number[] : Optional. Sensitivities for detecting keywords. Each value should be a number within [0, 1].
Returns
Promise<Porcupine>
: An instance of Porcupine Wake Word engine.
Porcupine.delete()
Releases resources acquired by Porcupine
.
Porcupine.frameLength
Getter for number of audio samples per frame.
Returns
number
: Number of audio samples per frame.
Porcupine.sampleRate
Getter for audio sample rate accepted by Picovoice.
Returns
number
: Audio sample rate accepted by Picovoice.
Porcupine.version
Getter for version.
Returns
string
: CurrentPorcupine
version.
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 .frameLength
. The incoming audio needs to have a sample rate equal to .sampleRate
and be 16-bit linearly-encoded. Porcupine operates on single-channel audio.
Parameters
frame
number[] : A frame of audio samples.
Returns
Promise<number>
: 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.
BuiltInKeywords
Enum of available built-in keywords for Porcupine Wake Word engine.
Values:
ALEXA
= "alexa"AMERICANO
= "americano"BLUEBERRY
= "blueberry"BUMBLEBEE
= "bumblebee"COMPUTER
= "computer"GRAPEFRUIT
= "grapefruit"GRASSHOPPER
= "grasshopper"HEY_GOOGLE
= hey google"HEY_SIRI
= hey siri"JARVIS
= "jarvis"OK_GOOGLE
= ok google"PICOVOICE
= "picovoice"PORCUPINE
= "porcupine"TERMINATOR
= "terminator"
PorcupineError
Exception thrown if an error occurs within Porcupine
Wake Word engine.
Exceptions:
PorcupineManager
High-level React Native binding for Porcupine
Wake Word engine. It handles recording audio from microphone, processes it in real-time using Porcupine, and notifies the client when any of the given keywords are detected.
PorcupineManager.fromBuiltInKeywords()
Porcupine
constructor when using built-in keywords.
Parameters
accessKey
string : AccessKey obtained from Picovoice Console.keywords
BuiltInKeyword[] : List of built-in keywords for detection.detectionCallback
DetectionCallback : A callback for when Porcupine detects the specified keywords.processErrorCallback
ProcessErrorCallback : Optional. A callback for when Porcupine process function triggers an error.modelPath
string : Optional. Absolute path to the file containing model parameters (.pv
). Can be relative to the assets/resource folder or an absolute path to the file on device.sensitivities
number[] : Optional. Sensitivities for detecting keywords. Each value should be a number within [0, 1].
Returns
Promise<Porcupine>
: An instance of Porcupine Wake Word engine.
PorcupineManager.fromKeywordPaths()
Porcupine
constructor when using keyword paths.
Parameters
accessKey
string : AccessKey obtained from Picovoice Console.keywordPaths
string[] : List of paths to keyword files (.ppn
). Can be relative to the assets/resource folder or absolute paths to the files on device.detectionCallback
DetectionCallback : A callback for when Porcupine detects the specified keywords.processErrorCallback
ProcessErrorCallback : Optional. A callback for when Porcupine process function triggers an error.modelPath
string : Optional. Absolute path to the file containing model parameters (.pv
). Can be relative to the assets/resource folder or an absolute path to the file on device.sensitivities
number[] : Optional. Sensitivities for detecting keywords. Each value should be a number within [0, 1].
Returns
Promise<Porcupine>
: An instance of Porcupine Wake Word engine.
PorcupineManager.delete()
Releases resources acquired by PorcupineManager
.
PorcupineManager.start()
Starts recording audio from the microphone and monitors it for the utterances of the given set of keywords.
PorcupineManager.stop()
Stops recording audio from the microphone.
DetectionCallback
Callback interface invoked when a keyword has been detected.
ProcessErrorCallback
Callback interface invoked when an error occurs while processing audio.