Rhino Speech-to-Intent
React Native API
API Reference for the React Native Rhino SDK (npm)
Rhino
Class for the Rhino Speech-To-Intent engine.
Rhino.create()
Rhino
constructor.
Parameters
accessKey
string : AccessKey obtained from Picovoice Console.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.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.sensitivity
number : Optional. Inference sensitivity. Each value should be a number within [0, 1].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 totrue
, Rhino requires an endpoint (a chunk of silence) after the spoken command. If set tofalse
, Rhino tries to detect silence, but if it cannot, it still will provide inference regardless. Set tofalse
only if operating in an environment with overlapping speech (e.g. people talking in the background).
Returns
Promise<Rhino>
: An instance of Rhino Speech-To-Intent engine.
Rhino.delete()
Releases resources acquired by Rhino
.
Rhino.contextInfo
Getter for Rhino context info.
Returns
string
: Gets the source of the Rhino context in YAML format.
Rhino.frameLength
Getter for number of audio samples per frame.
Returns
number
: Number of audio samples per frame.
Rhino.sampleRate
Getter for audio sample rate accepted by Picovoice.
Returns
number
: Audio sample rate accepted by Picovoice.
Rhino.version
Getter for version.
Returns
string
: CurrentRhino
version.
Rhino.process()
Processes a frame of the incoming audio stream and emits the inference 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. Rhino operates on single-channel audio.
Parameters
frame
number[] : A frame of audio samples.
Returns
Promise<RhinoInference>
: Inference result at time of frame being processed.
Rhino.reset()
Resets the internal state of Rhino. It should be called before the engine can be used to infer intent from a new stream of audio.
RhinoInference
Class to contain Rhino inference data.
RhinoInference.isFinalized
Getter for the isFinalized
flag.
Returns
boolean
: Iftrue
,Rhino
has made an inference.
RhinoInference.isUnderstood
public get isUnderstood(): boolean | undefined
Returns
boolean | undefined
: Iftrue
,Rhino
understood the intent.
RhinoInference.intent
Getter for the inference intent name.
Returns
string | undefined
: Inference intent name.
RhinoInference.slots
Getter for the inference slots and values.
Returns
{[key: string]: string} | undefined
: Map for inference slots and values.
RhinoError
Exception thrown if an error occurs within Rhino
Speech-To-Intent engine.
Exceptions:
RhinoManager
High-level React Native binding for Rhino
Speech-To-Intent engine. It handles recording audio from microphone, processes it in real-time using Rhino, and notifies the client when an inference is detected.
RhinoManager.create()
Rhino
constructor.
Parameters
accessKey
string : AccessKey obtained from Picovoice Console.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 : A callback for when Rhino detects the specified keywords.processErrorCallback
ProcessErrorCallback : Optional. A callback for when Rhino has made an intent inference.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.sensitivity
number : Optional. Sensitivities for detecting keywords. Each value should be a number within [0, 1].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 totrue
, Rhino requires an endpoint (a chunk of silence) after the spoken command. If set tofalse
, Rhino tries to detect silence, but if it cannot, it still will provide inference regardless. Set tofalse
only if operating in an environment with overlapping speech (e.g. people talking in the background).
Returns
Promise<Rhino>
: An instance of Rhino Speech-To-Intent engine.
RhinoManager.delete()
Releases resources acquired by RhinoManager
.
RhinoManager.process()
Starts recording audio from the microphone and tries to infer intent. When RhinoManager
returns an inference result via the inferenceCallback
, it will automatically stop audio capture for you. When you wish to result, call .process()
again.
RhinoManager.contextInfo
Getter for Rhino context info.
Returns
string | undefined
: Gets the source of the Rhino context in YAML format.
RhinoManager.frameLength
Getter for number of audio samples per frame.
Returns
number | undefined
: Number of audio samples per frame.
RhinoManager.sampleRate
Getter for audio sample rate accepted by Picovoice.
Returns
number | undefined
: Audio sample rate accepted by Picovoice.
RhinoManager.version
Getter for version.
Returns
string | undefined
: CurrentRhino
version.
InferenceCallback
Callback interface invoked when an inference is finished.
ProcessErrorCallback
Callback interface invoked when an error occurs while processing audio.