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
React Native API


API Reference for the React Native Porcupine SDK (npm)


Porcupine

class Porcupine { }

Class for the Porcupine Wake Word engine.

Use this class when using a custom audio processing pipeline. Otherwise it is recommended to use the PorcupineManager High-Level API, which contains integrated audio recording.

Porcupine.fromBuiltInKeywords()

public static async fromBuiltInKeywords(
accessKey: string,
keywords: BuiltInKeywords[],
modelPath: string = '',
sensitivities: number[] = []
)

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

public static async fromKeywordPaths(
accessKey: string,
keywordsPaths: string[],
modelPath: string = '',
sensitivities: number[] = []
)

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

async delete()

Releases resources acquired by Porcupine.


Porcupine.frameLength

get frameLength()

Getter for number of audio samples per frame.

Returns

  • number: Number of audio samples per frame.

Porcupine.sampleRate

get sampleRate()

Getter for audio sample rate accepted by Picovoice.

Returns

  • number: Audio sample rate accepted by Picovoice.

Porcupine.version

get version()

Getter for version.

Returns

  • string: Current Porcupine version.

Porcupine.process()

async process(frame: number[]): Promise<number>

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 .sampleRateand 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 BuiltInKeyword { }

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

class PorcupineError extends Error { }

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

Exceptions:

class PorcupineActivationError extends PorcupineError { }
class PorcupineActivationLimitError extends PorcupineError { }
class PorcupineActivationRefusedError extends PorcupineError { }
class PorcupineActivationThrottledError extends PorcupineError { }
class PorcupineIOError extends PorcupineError { }
class PorcupineInvalidArgumentError extends PorcupineError { }
class PorcupineInvalidStateError extends PorcupineError { }
class PorcupineKeyError extends PorcupineError { }
class PorcupineMemoryError extends PorcupineError { }
class PorcupineRuntimeError extends PorcupineError { }
class PorcupineStopIterationError extends PorcupineError { }

PorcupineManager

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

This class offers integrated audio capture. For use-cases where there is already an audio-processing pipeline in place, use the Porcupine Low-Level API.

PorcupineManager.fromBuiltInKeywords()

public static async fromBuiltInKeywords(
accessKey: string,
keywords: BuiltInKeywords[],
detectionCallback: DetectionCallback,
processErrorCallback?: ProcessErrorCallback,
modelPath?: string,
sensitivities?: number[]
)

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

public static async fromKeywordPaths(
accessKey: string,
keywordPaths: string[],
detectionCallback: DetectionCallback,
processErrorCallback?: ProcessErrorCallback,
modelPath?: string,
sensitivities?: number[]
)

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

public delete()

Releases resources acquired by PorcupineManager.


PorcupineManager.start()

public async start()

Starts recording audio from the microphone and monitors it for the utterances of the given set of keywords.


PorcupineManager.stop()

public async stop()

Stops recording audio from the microphone.


DetectionCallback

type DetectionCallback = (keywordIndex: number) => void;

Callback interface invoked when a keyword has been detected.


ProcessErrorCallback

type ProcessErrorCallback = (error: PorcupineErrors.PorcupineError) => void;

Callback interface invoked when an error occurs while processing audio.

Was this doc helpful?

Issue with this doc?

Report a GitHub Issue
Porcupine Wake Word React Native API
  • Porcupine
  • fromBuiltInKeywords()
  • fromKeywordPaths()
  • delete()
  • frameLength
  • sampleRate
  • version
  • process()
  • BuiltInKeywords
  • PorcupineError
  • PorcupineManager
  • fromBuiltInKeywords()
  • fromKeywordPaths()
  • delete()
  • start()
  • stop()
  • DetectionCallback
  • ProcessErrorCallback
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.