reactRhino - React API

API Reference for the Rhino React SDK.


useRhino()

function useRhino(
rhinoWorkerFactory: RhinoWorkerFactory | null,
rhinoHookArgs: RhinoHookArgs | null,
inferenceCallback: (inference: RhinoInferenceFinalized) => void
)

React Hook for Rhino Speech-to-Intent engine

Parameters

  • rhinoWorkerFactory RhinoWorkerFactory : The language-specific worker factory, imported as { RhinoWorkerFactory } from the @picovoice/rhino-web-xx-worker series of packages, where xx is the two-letter language code.
  • rhinoHookArgs RhinoHookArgs : useRhino Hook Parameters.
  • inferenceCallback (inference: RhinoInferenceFinalized) => void : User-defined callback invoked upon completion of intent inference.

Returns

  • contextInfostring : Context information.
  • isLoaded boolean : A state indicating whether the engine is initialized successfully.
  • isListening boolean : A state indicating whether the webVoiceProcessor is passing audio to the engine.
  • isError boolean : A state indicating whether the Hook returned an error.
  • isTalking boolean : A state indicating whether the Rhino engine actively listening microphone audio until it reaches a conclusion.
  • errorMessage string : A string expression of the error.
  • webVoiceProcessor WebVoiceProcessor : A pointer to the internal webVoiceProcessor object.
  • start () => void : A method to start processing audio.
  • pause () => void : A method to stop processing audio.
  • pushToTalk () => void : A method to put Rhino in an active isTalking state.

RhinoHookArgs

type RhinoHookArgs = {
accessKey: string;
context: RhinoContext;
requireEndpoint?: boolean;
start?: boolean;
isTalking?: boolean;
};

Type alias for the Hook Parameters

Parameters

  • accessKey string : AccessKey obtained from Picovoice Console.
  • context RhinoContext : The context to instantiate.
  • requireEndpoint boolean : If set to true, Rhino requires an endpoint (chunk of silence) before finishing inference.
  • start boolean : If set to true, the Rhino Hook immediately starts the microphone upon initialization.
  • isTalking boolean : If set to true, Rhino is immediately put in an active 'isTalking' state upon initialization (default: false).

RhinoContext

type RhinoContext = {
base64: string;
sensitivity?: number;
};

Type alias for the Rhino context

Parameters

  • base64 string : Base64 representation of a trained Rhino context (.rhn file).
  • sensitivity number : Value in range [0,1] that trades off miss rate for false alarm. If not set 0.5 will be used.

RhinoInference

type RhinoInference = {
isFinalized: boolean;
isUnderstood?: boolean;
intent?: string;
slots?: Record<string, string>;
};

Type alias for the Rhino inference

Parameters

  • isFinalized: Indicates whether Rhino has concluded an inference.
  • isUnderstood boolean : Indicates whether the intent was understood.
  • intent string : The name of the intent.
  • slots Record : Map of the slot variables and values extracted from the utterance.


Issue with this doc? Please let us know.