Rhino - React Native API
API Reference for the React Native Rhino SDK (npm)
Rhino
class Rhino { }
Class for the Rhino Speech-To-Intent engine.
Rhino.create()
public static async create(accessKey: string,contextPath: string,modelPath?: string,sensitivity: number = 0.5,requireEndpoint: boolean = true): Promise<Rhino>
Rhino
constructor.
Parameters
accessKey
string : AccessKey obtained from Picovoice Console.contextPath
string : Absolute path to Rhino context file (.rhn
).modelPath
string : Optional. Absolute path to the file containing model parameters (.pv
).sensitivity
number : Optional. Inference sensitivity. Each value should be a number within [0, 1].requireEndpoint
boolean : Optional. If true, Rhino requires an endpoint (chunk of silence) before finishing inference.
Returns
Promise<Rhino>
: An instance of Rhino Speech-To-Intent engine.
Rhino.delete()
async delete()
Releases resources acquired by Rhino
.
Rhino.contextInfo
get contextInfo()
Getter for Rhino context info.
Returns
string
: Gets the source of the Rhino context in YAML format.
Rhino.frameLength
get frameLength()
Getter for number of audio samples per frame.
Returns
number
: Number of audio samples per frame.
Rhino.sampleRate
get sampleRate()
Getter for audio sample rate accepted by Picovoice.
Returns
number
: Audio sample rate accepted by Picovoice.
Rhino.version
get version()
Getter for version.
Returns
string
: CurrentRhino
version.
Rhino.process()
async process(frame: number[]): Promise<RhinoInference>
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.
RhinoInference
export class RhinoInference { }
Class to contain Rhino inference data.
RhinoInference.isFinalized
get isFinalized()
Getter for the isFinalized
flag.
Returns
boolean
: Iftrue
,Rhino
has made an inference.
RhinoInference.isUnderstood
get isUnderstood()
Getter for the isUnderstood
flag.
Returns
boolean
: Iftrue
,Rhino
understood the intent.
RhinoInference.intent
get intent()
Getter for the inference intent name.
Returns
string
: Inference intent name.
RhinoInference.slots
get slots()
Getter for the inference slots and values.
Returns
{[key: string]: string}
: Map for inference slots and values.
RhinoError
class RhinoError extends Error { }
Exception thrown if an error occurs within Rhino
Speech-To-Intent engine.
Exceptions:
class RhinoActivationError extends RhinoError { }class RhinoActivationLimitError extends RhinoError { }class RhinoActivationRefusedError extends RhinoError { }class RhinoActivationThrottledError extends RhinoError { }class RhinoIOError extends RhinoError { }class RhinoInvalidArgumentError extends RhinoError { }class RhinoInvalidStateError extends RhinoError { }class RhinoKeyError extends RhinoError { }class RhinoMemoryError extends RhinoError { }class RhinoRuntimeError extends RhinoError { }class RhinoStopIterationError extends RhinoError { }
RhinoManager
class 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()
public static async create(accessKey: string,contextPath: string,inferenceCallback: InferenceCallback,processErrorCallback?: ProcessErrorCallback,modelPath?: string,sensitivity: number = 0.5,requireEndpoint: boolean = true): Promise<Rhino>
Rhino
constructor.
Parameters
accessKey
string : AccessKey obtained from Picovoice Console.contextPath
string : Absolute path to Rhino context file (.rhn
).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. Absolute path to the file containing model parameters (.pv
).sensitivities
number[] : Optional. Sensitivities for detecting keywords. Each value should be a number within [0, 1].requireEndpoint
boolean : Optional. If true, Rhino requires an endpoint (chunk of silence) before finishing inference.
Returns
Promise<Rhino>
: An instance of Rhino Speech-To-Intent engine.
RhinoManager.delete()
public delete()
Releases resources acquired by RhinoManager
.
RhinoManager.process()
public async 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.
InferenceCallback
type InferenceCallback = (inference: RhinoInference) => void;
Callback interface invoked when an inference is finished.
ProcessErrorCallback
type ProcessErrorCallback = (error: RhinoErrors.RhinoError) => void;
Callback interface invoked when an error occurs while processing audio.