wasmRhino - 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 to false, Rhino does not require an endpoint (chunk of silence) before finishing an inference. Default value is true.

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


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: boolean
isUnderstood?: boolean
intent?: string
slots?: Record<string, string>
}

Type containing inference result data returned from the Rhino engine.

Parameters

  • isFinalized boolean : When true, Rhino has concluded the inference.
  • isUnderstood boolean : If isFinalized, indicates if the intent was understood based on the context.
  • intent string : If isUnderstood, the name of the intent that was inferred.
  • slots Record<string, string> : If isUnderstood, 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 to false, Rhino does not require an endpoint (chunk of silence) before finishing an inference. Default value is true.
  • 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

Returns


Issue with this doc? Please let us know.