Rhino Speech-to-Intent
Web API
API Reference for the Rhino Web SDK (npmjs).
Rhino
Class for the Rhino Speech-to-Intent engine.
Rhino.create()
Creates an instance of the Rhino Speech-to-Intent engine. The model size is large, hence it will try to use the existing one if it exists, otherwise saves the model in storage.
Parameters
accessKey
string : AccessKey obtained from Picovoice Console.context
RhinoContext : Object containing Rhino context data.inferenceCallback
InferenceCallback : User-defined callback invoked upon processing a frame of audio.model
RhinoModel : Object containing Rhino model data.options
RhinoOptions : Optional configuration arguments.
Returns
Rhino
: An instance of the Rhino engine.
Rhino.process()
Processes a frame of audio. The required sample rate can be retrieved from .sampleRate
and the length of frame (number of audio samples per frame) can be retrieved from .frameLength
.
The audio must be single-channel and 16-bit linearly-encoded.
Detected inferences are returned via the inferenceCallback
callback.
Parameters
pcm
Int16Array : A frame of audio.
Rhino.reset()
Resets the internal Rhino state.
Rhino.release()
Releases resources acquired by the Rhino Web SDK.
Rhino.contextInfo
Stores the source of the Rhino context in YAML format. Shows the list of intents, which expressions map to those intents, as well as slots and their possible values.
Rhino.frameLength
Number of audio samples per frame.
Rhino.sampleRate
Audio sample rate accepted by Rhino.
Rhino.version
Rhino version string.
RhinoWorker
Class for creating instances of the RhinoWorker
.
RhinoWorker.create()
Creates a worker instance of the RhinoWorker
using a base64'd string of the model file.
The model size is large, hence it will try to use the existing one if it exists, otherwise saves the model in storage.
Parameters
accessKey
string : AccessKey obtained from Picovoice Console.context
RhinoContext : Object containing Rhino context data.inferenceCallback
InferenceCallback : User-defined callback invoked upon processing a frame of audio.model
RhinoModel : Object containing Rhino model data.options
RhinoOptions : Optional configuration arguments.
Returns
RhinoWorker
: An instance ofRhinoWorker
.
RhinoWorker.process()
Processes a frame of audio. The required sample rate can be retrieved from .sampleRate
and the length of frame (number of audio samples per frame) can be retrieved from .frameLength
.
The audio must be single-channel and 16-bit linearly-encoded.
Detected inferences are returned via the inferenceCallback
callback.
Parameters
pcm
Int16Array : A frame of audio.
RhinoWorker.reset()
Resets the internal Rhino state.
RhinoWorker.release()
Releases resources acquired by the Rhino Web SDK.
RhinoWorker.terminate()
Terminates the active worker. Stops all requests being handled by worker.
RhinoWorker.contextInfo
Stores the source of the Rhino context in YAML format. Shows the list of intents, which expressions map to those intents, as well as slots and their possible values.
RhinoWorker.frameLength
Number of audio samples per frame.
RhinoWorker.sampleRate
Audio sample rate accepted by Rhino.
RhinoWorker.version
Rhino version string.
InferenceCallback
Type defining the interface for the user-defined inferenceCallback
used to receive inference results from the Rhino engine.
Parameters
inference
RhinoInference : Inference data.
RhinoInference
Type containing inference result data returned from the Rhino engine.
Parameters
isFinalized
boolean : Whentrue
, Rhino has concluded the inference.isUnderstood
boolean : IfisFinalized
, indicates if the intent was understood based on the context.intent
string : IfisUnderstood
, the name of the intent that was inferred.slots
Record<string, string> : IfisUnderstood
, a map of the slot keys and values that were inferred.
RhinoContext
Type representing a context created using the Picovoice Console. One of base64
or publicPath
must be specified.
Parameters
base64
string : Optional. Base64 representation of a trained Rhino context (.rhn
file).publicPath
string : Optional. The Rhino context (.rhn
file) path relative to the public directory.customWritePath
string : Optional. Custom path to save the model in storage.forceWrite
boolean : Optional. A flag that indicates whether to overwrite the context in storage even if it exists.version
number : Optional. Version of file in storage. Set to a higher number to update the model file.sensitivity
number : Optional. Inference sensitivity. It should be a number within [0, 1]. A higher sensitivity value results in fewer misses at the cost of (potentially) increasing the erroneous inference rate.
RhinoModel
Type representing a context created using the Picovoice Console. One of base64
or publicPath
must be specified.
Parameters
base64
string : Optional. Base64 representation of a Rhino parameter model (.pv
file).publicPath
string : Optional. The Rhino parameter model (.pv
file) path relative to the public directory.customWritePath
string : Optional. Custom path to save the model in storage.forceWrite
boolean : Optional. A flag that indicates whether to overwrite the context in storage even if it exists.version
number : Optional. Version of file in storage. Set to a higher number to update the model file.
RhinoOptions
Type containing optional arguments used then creating an instance of Rhino
.
Parameters
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 preemptively 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).processErrorCallback
(error: string) => void : Optional. Callback invoked if an error is encountered when calling.process()
.
RhinoError
Error thrown if an error occurs within Rhino
Speech-to-Intent engine.
Errors: