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


API Reference for the React Native Picovoice SDK (npm)


Picovoice

class Picovoice { }

Class for the Picovoice platform.

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

Picovoice.create()

public static async create(
accessKey: string,
keywordPath: string,
wakeWordCallback: WakeWordCallback,
contextPath: string,
inferenceCallback: InferenceCallback,
porcupineSensitivity: number = 0.5,
rhinoSensitivity: number = 0.5,
porcupineModelPath?: string,
rhinoModelPath?: string,
endpointDurationSec: number = 1.0,
requireEndpoint: boolean = true
): Promise<Picovoice>

Picovoice constructor.

Parameters

  • accessKey string : AccessKey obtained from Picovoice Console.
  • keywordPath string : Path to Porcupine keyword file (.ppn). Can be relative to the assets/resource folder or an absolute path to the file on device.
  • wakeWordCallback WakeWordCallback : User-defined callback invoked upon detection of the wake phrase.
  • contextPath string : Path to Rhino context file (.rhn). Can be relative to the assets/resource folder or an absolute path to the file on device.
  • inferenceCallback InferenceCallback : User-defined callback invoked upon completion of intent inference.
  • porcupineSensitivity number : Optional. Wake word detection sensitivity. It should be a number within [0, 1].
  • rhinoSensitivity number : Optional. Inference sensitivity. It should be a number within [0, 1].
  • porcupineModelPath string : Optional. Path to the file containing Porcupine's model parameters (.pv). Can be relative to the assets/resource folder or an absolute path to the file on device.
  • rhinoModelPath string : Optional. Path to the file containing Rhino's model parameters (.pv). Can be relative to the assets/resource folder or an absolute path to the file on device.
  • endpointDurationSec number : Optional. 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 boolean : Optional. 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

  • Promise<Picovoice>: An instance of Picovoice platform.

Picovoice.delete()

async delete()

Releases resources acquired by Picovoice.


Picovoice.contextInfo

get contextInfo()

Getter for Rhino context info.

Returns

  • string: Gets the source of the Rhino context in YAML format.

Picovoice.frameLength

get frameLength()

Getter for number of audio samples per frame.

Returns

  • number: Number of audio samples per frame.

Picovoice.sampleRate

get sampleRate()

Getter for audio sample rate accepted by Picovoice.

Returns

  • number: Audio sample rate accepted by Picovoice.

Picovoice.version

get version()

Getter for version.

Returns

  • string: Current Picovoice version.

Picovoice.porcupineVersion

get porcupineVersion()

Getter for Porcupine version.

Returns

  • string: Current Porcupine version.

Picovoice.rhinoVersion

get rhinoVersion()

Getter for Rhino version.

Returns

  • string: Current Rhino version.

Picovoice.process()

async process(frame: number[])

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

Parameters

  • frame number[] : A frame of audio samples.

PicovoiceError

class PicovoiceError extends Error { }

Exception thrown if an error occurs within Picovoice platform.

Exceptions:

class PicovoiceActivationError extends PicovoiceError { }
class PicovoiceActivationLimitError extends PicovoiceError { }
class PicovoiceActivationRefusedError extends PicovoiceError { }
class PicovoiceActivationThrottledError extends PicovoiceError { }
class PicovoiceIOError extends PicovoiceError { }
class PicovoiceInvalidArgumentError extends PicovoiceError { }
class PicovoiceInvalidStateError extends PicovoiceError { }
class PicovoiceKeyError extends PicovoiceError { }
class PicovoiceMemoryError extends PicovoiceError { }
class PicovoiceRuntimeError extends PicovoiceError { }
class PicovoiceStopIterationError extends PicovoiceError { }

PicovoiceManager

class PicovoiceManager { }

High-level React Native API for Picovoice platform. It handles recording audio from the microphone, processes it in real-time using Picovoice, and notifies the client when a keyword has been detected or an inference has been completed.

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

PicovoiceManager.create()

public static async create(
accessKey: string,
keywordPath: string,
wakeWordCallback: WakeWordCallback,
contextPath: string,
inferenceCallback: InferenceCallback,
processErrorCallback?: ProcessErrorCallback,
porcupineSensitivity: number = 0.5,
rhinoSensitivity: number = 0.5,
porcupineModelPath?: string,
rhinoModelPath?: string,
endpointDurationSec: number = 1.0,
requireEndpoint: boolean = true
): Promise<Picovoice>

Picovoice constructor.

Parameters

  • accessKey string : AccessKey obtained from Picovoice Console.
  • keywordPath string : Path to Porcupine keyword file (.ppn). Can be relative to the assets/resource folder or an absolute path to the file on device.
  • wakeWordCallback WakeWordCallback : User-defined callback invoked upon detection of the wake phrase.
  • contextPath string : Path to file containing Rhino context parameters (.rhn). Can be relative to the assets/resource folder or an absolute path to the file on device.
  • inferenceCallback InferenceCallback : User-defined callback invoked upon completion of intent inference.
  • processErrorCallback ProcessErrorCallback : Optional. Reports errors that are encountered while the engine is processing audio.
  • porcupineSensitivity number : Optional. Wake word detection sensitivity. It should be a number within [0, 1].
  • rhinoSensitivity number : Optional. Inference sensitivity. It should be a number within [0, 1].
  • porcupineModelPath string : Optional. Path to the file containing Porcupine's model parameters (.pv). Can be relative to the assets/resource folder or an absolute path to the file on device.
  • rhinoModelPath string : Optional. Path to the file containing Rhino's model parameters (.pv). Can be relative to the assets/resource folder or an absolute path to the file on device.
  • endpointDurationSec number : Optional. 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 boolean : Optional. 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

  • Promise<Picovoice>: An instance of Picovoice platform.

PicovoiceManager.start()

public async start()

Starts recording audio from the microphone and passed it to the Picovoice Platform.


PicovoiceManager.stop()

public async stop()

Stops recording audio from the microphone.


InferenceCallback

type InferenceCallback = (inference: RhinoInference) => void;

Callback interface invoked when an inference is finished. The callback takes a single parameter of type RhinoInference.


WakeWordCallback

type WakeWordCallback = () => void;

Callback interface invoked when the keyword is detected.


ProcessErrorCallback

type ProcessErrorCallback = (error: PicovoiceErrors.PicovoiceError) => void;

Callback interface invoked when an error occurs while processing audio.

Was this doc helpful?

Issue with this doc?

Report a GitHub Issue
Picovoice Platform React Native API
  • Picovoice
  • create()
  • delete()
  • contextInfo
  • frameLength
  • sampleRate
  • version
  • porcupineVersion
  • rhinoVersion
  • process()
  • PicovoiceError
  • PicovoiceManager
  • create()
  • start()
  • stop()
  • InferenceCallback
  • WakeWordCallback
  • 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.