Picovoice Platform — React Native API
API Reference for the React Native Picovoice SDK (npm)
Picovoice
class Picovoice { }
Class for the Picovoice platform.
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,requireEndpoint: boolean = true): Promise<Picovoice>
Picovoice
constructor.
Parameters
accessKey
string : AccessKey obtained from Picovoice Console.keywordPath
string : Absolute path to Porcupine's keyword model file (.ppn
).wakeWordCallback
WakeWordCallback : User-defined callback invoked upon detection of the wake phrase.contextPath
string : Absolute path to file containing Rhino context parameters (.rhn
).inferenceCallback
InferenceCallback : User-defined callback invoked upon completion of intent inference.porcupineSensitivity
number : Wake word detection sensitivity. It should be a number within [0, 1].rhinoSensitivity
number : Inference sensitivity. It should be a number within [0, 1].porcupineModelPath
string : Absolute path to the file containing Porcupine's model parameters (.pv
).rhinoModelPath
string : Absolute path to the file containing Rhino's model parameters (.pv
).requireEndpoint
string : If true, Rhino requires an endpoint (chunk of silence) before finishing inference.
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
: CurrentPicovoice
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.
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,requireEndpoint: boolean = true): Promise<Picovoice>
Picovoice
constructor.
Parameters
accessKey
string : AccessKey obtained from Picovoice Console.keywordPath
string : Absolute path to Porcupine's keyword model file (.ppn
).wakeWordCallback
WakeWordCallback : User-defined callback invoked upon detection of the wake phrase.contextPath
string : Absolute path to file containing Rhino context parameters (.rhn
).inferenceCallback
InferenceCallback : User-defined callback invoked upon completion of intent inference.processErrorCallback
ProcessErrorCallback : Reports errors that are encountered while the engine is processing audio.porcupineSensitivity
number : Wake word detection sensitivity. It should be a number within [0, 1].rhinoSensitivity
number : Inference sensitivity. It should be a number within [0, 1].porcupineModelPath
string : Absolute path to the file containing Porcupine's model parameters (.pv
).rhinoModelPath
string : Absolute path to the file containing Rhino's model parameters (.pv
).requireEndpoint
string : If true, Rhino requires an endpoint (chunk of silence) before finishing inference.
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.