Rhino - Web API
API Reference for the Rhino Web SDK.
Rhino
class Rhino implements RhinoEngine
Class for the Rhino Speech-to-Intent engine.
Rhino.create()
static async function create(accessKey: string,contextInfo: RhinoContext,requireEndpoint?: boolean): Promise<Rhino>
Creates an instance of the Rhino Speech-to-Intent engine.
Parameters
accessKey
string : AccessKey obtained from Picovoice Console.contextInfo
RhinoContext : Object containing Rhino context data.requireEndpoint
boolean : If set tofalse
, Rhino does not require an endpoint (chunk of silence) before finishing an inference. Default value istrue
.
Returns
Rhino
: An instance of the Rhino engine.
Rhino.process()
async function process(pcm: Int16Array): Promise<RhinoInference>
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.
Parameters
pcm
Int16Array : A frame of audio.
Returns
RhinoInference
: Object containing Rhino inference data.
Rhino.release()
async function release(): Promise<void>
Releases resources acquired by the Rhino Web SDK.
Rhino.contextInfo
get contextInfo(): number
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
get framelength(): number
Number of audio samples per frame.
Rhino.sampleRate
get sampleRate(): number
Audio sample rate accepted by Rhino.
Rhino.version
get version(): string
Rhino version string.
RhinoInference
export type RhinoInference = {isFinalized: booleanisUnderstood?: booleanintent?: stringslots?: Record<string, string>}
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
export type RhinoInference = {base64: string,sensitivity?: number}
Type representing a context created using the Picovoice Console.
Parameters
base64
string : Base64 representation of a trained Rhino context (.rhn
file).sensitivity
number : Inference sensitivity. A higher sensitivity value results in fewer misses at the cost of (potentially) increasing the erroneous inference rate. Sensitivity should be a floating-point number within 0 and 1.
RhinoArgs
export type RhinoArgs = {accessKey: string;context: RhinoContext;requireEndpoint?: boolean;start: boolean;}
Type containing data used to construct a RhinoWorker
.
Parameters
accessKey
string : AccessKey obtained from Picovoice Console.context
RhinoContext : Object containing Rhino context data.requireEndpoint
boolean : If set tofalse
, Rhino does not require an endpoint (chunk of silence) before finishing an inference. Default value istrue
.start
boolean : Indicates if worker should begin accepting audio as soon as it's initialized.
RhinoWorker
export interface RhinoWorker extends Omit<Worker, 'postMessage'>
Interface for the Rhino web worker.
RhinoWorkerFactory
class RhinoWorkerFactory
A factory class for creating new instances of the RhinoWorker
web worker.
RhinoWorkerFactory.create()
static async function create(rhinoArgs: RhinoArgs): Promise<RhinoWorker>
Creates Rhino web worker instances. The promise resolves when the worker is ready to process voice data.
Parameters
rhinoArgs
RhinoArgs : Object containing data required to create aRhinoWorker
.
Returns
RhinoWorker
: A Rhino web worker.