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
accessKeystring : AccessKey obtained from Picovoice Console.contextRhinoContext : Object containing Rhino context data.inferenceCallbackInferenceCallback : User-defined callback invoked upon processing a frame of audio.modelRhinoModel : Object containing Rhino model data.optionsRhinoOptions : 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
pcmInt16Array : 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
accessKeystring : AccessKey obtained from Picovoice Console.contextRhinoContext : Object containing Rhino context data.inferenceCallbackInferenceCallback : User-defined callback invoked upon processing a frame of audio.modelRhinoModel : Object containing Rhino model data.optionsRhinoOptions : 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
pcmInt16Array : 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
inferenceRhinoInference : Inference data.
RhinoInference
Type containing inference result data returned from the Rhino engine.
Parameters
isFinalizedboolean : Whentrue, Rhino has concluded the inference.isUnderstoodboolean : IfisFinalized, indicates if the intent was understood based on the context.intentstring : IfisUnderstood, the name of the intent that was inferred.slotsRecord<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
base64string : Optional. Base64 representation of a trained Rhino context (.rhnfile).publicPathstring : Optional. The Rhino context (.rhnfile) path relative to the public directory.customWritePathstring : Optional. Custom path to save the model in storage.forceWriteboolean : Optional. A flag that indicates whether to overwrite the context in storage even if it exists.versionnumber : Optional. Version of file in storage. Set to a higher number to update the model file.sensitivitynumber : 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
base64string : Optional. Base64 representation of a Rhino parameter model (.pvfile).publicPathstring : Optional. The Rhino parameter model (.pvfile) path relative to the public directory.customWritePathstring : Optional. Custom path to save the model in storage.forceWriteboolean : Optional. A flag that indicates whether to overwrite the context in storage even if it exists.versionnumber : 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
endpointDurationSecnumber : 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.requireEndpointboolean : 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 tofalseonly 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: