Picovoice Platform
React API
API Reference for the Picovoice React SDK (npmjs).
usePicovoice()
React Hook for Picovoice
Platform.
Returns
wakeWordDetection
PorcupineDetection | null : A state that is updated when the wake word has been detected.inference
RhinoInference | null : A state that is updated when an inference has been made.contextInfo
string | null : A state that updates when Rhino context info is available. Shows the list of intents, which expressions map to those intents, as well as slots and their possible values.isLoaded
boolean : A state indicating whether the engine is initialized successfully.isListening
boolean : A state indicating whether thewebVoiceProcessor
is passing audio to the engine.error
Error | null : AnError
object containing details about the error.init
(...) => Promise<void> : A method to initialize the internalPicovoiceWorker
. Seeinit
.start
() => Promise<void> : A method to start processing the audio. Seestart
.stop
() => Promise<void> : A method to stop processing the audio. Seestop
.release
() => Promise<void> : Releases resources acquired byusePicovoice
. Seerelease
init()
Initializes the internal PicovoiceWorker
. Sets isLoaded
state to true
if successful.
Parameters
accessKey
string : AccessKey obtained from Picovoice Console.keyword
PorcupineKeyword : A Porcupine keyword. Can be provided as a built-in, base64 or a hosted.ppn
file.porcupineModel
PorcupineModel : Contains the model parameters that are used to initialize the Porcupine engine. Model can be encoded in base64 or can be stored in a.pv
file in a public directory.context
RhinoContext : A Rhino context. Can be provided as a base64 or a hosted.rhn
file.rhinoModel
RhinoModel : Contains the model parameters that are used to initialize the Rhino engine. Model can be encoded in base64 or can be stored in a.pv
file in a public directory.options
PicovoiceOptions : Optional configuration arguments.
start()
Starts audio recording and processing. If successful, isListening
is set to true
.
stop()
Stops audio recording and processing. If successful, isListening
is set to false
.
release()
Releases resources acquired by the usePicovoice
hook and resets all internal states.