Rhino - Angular API
API Reference for the Rhino Angular SDK (npm).
RhinoService
class RhinoService implements OnDestroy { }
Angular service for Rhino Speech-to-Intent engine.
RhinoService.init()
async init(rhinoWorkerFactory: RhinoWorkerFactory,rhinoServiceArgs: RhinoServiceArgs): Promise<void>
Initializes the RhinoService. Subscribe to the inference$
subject to receive inference events.
Parameters
rhinoWorkerFactory
RhinoWorkerFactory : The language-specific worker factory, imported as{ RhinoWorkerFactory }
from the@picovoice/rhino-web-xx-worker
series of packages, wherexx
is the two-letter language code.rhinoServiceArgs
RhinoServiceArgs :RhinoService
parameters.
RhinoService.inference$
inference$: Subject<RhinoInferenceFinalized>
Subject which is updated when an inference is finalized. See RhinoInferenceFinalized
.
RhinoService.listening$
listening$: Subject<boolean>
Subject indicating whether the WebVoiceProcessor
is passing audio to the engine.
RhinoService.isTalking$
isTalking$: Subject<boolean>
Subject indicating whether the Rhino engine actively listening microphone audio until it reaches a conclusion.
RhinoService.isError$
isError$: Subject<boolean>
Subject which indicates that an error has occurred. Use error$
to retrieve the error object.
RhinoService.error$
error$: Subject<Error | string>
Subject which contains the error object when an error has occurred. Use isError$
to determine if content is present.
RhinoService.pause()
pause(): boolean
Pauses audio input from the WebVoiceProcessor
and sets listening$
to false
.
Returns
boolean
:true
if pause was successful.
RhinoService.start()
start(): boolean
Starts audio input from the WebVoiceProcessor
and sets listening$
to true
.
Returns
boolean
:true
if start was successful.
RhinoService.release()
async release(): Promise<void>
Releases resources acquired by the RhinoService
and the WebVoiceProcessor
.
RhinoService.pushToTalk()
pushToTalk(): boolean
Puts the RhinoService
in an active isTalking$
state.
Returns
boolean
:true
if state change was successful.
RhinoServiceArgs
type RhinoServiceArgs = {accessKey: string;context: RhinoContext;requireEndpoint?: boolean;start?: boolean;};
Type alias for the RhinoService
parameters.
Parameters
accessKey
string : AccessKey obtained from Picovoice Console.context
RhinoContext : The context to instantiate.requireEndpoint
boolean : If set totrue
, Rhino requires an endpoint (chunk of silence) before finishing inference.start?
boolean : Optional. If set totrue
, theRhinoService
immediately starts the microphone upon initialization.
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 : Optional. Value in range [0,1] that trades off miss rate for false alarm. If not set 0.5 will be used.
RhinoInference
type RhinoInferenced = {isFinalized: boolean;isUnderstood: boolean;intent?: string;slots?: Record<string, string>;};
Type alias for the Rhino inference
Parameters
isFinalized
boolean: Indicates whether Rhino has concluded an inference.isUnderstood
boolean : Indicates whether the intent was understood.intent?
string : Optional. The name of the intent.slots?
Record<string, string> : Optional. Map of the slot variables and values extracted from the utterance.