angularPicovoice - Angular API

API Reference for the Picovoice Angular SDK (npm).


PicovoiceService

class PicovoiceService implements OnDestroy { }

Angular service for Picovoice.


PicovoiceService.init()

async init(
picovoiceWorkerFactory: PicovoiceWorkerFactory,
picovoiceServiceArgs: PicovoiceServiceArgs
): Promise<void>

Initializes the PicovoiceService. Subscribe to the keyword$ and inference$ subjects to receive events.

Parameters

  • picovoiceWorkerFactory PicovoiceWorkerFactory : The language-specific worker factory, imported as { PicovoiceWorkerFactory } from the @picovoice/picovoice-web-xx-worker series of packages, where xx is the two-letter language code.
  • picovoiceServiceArgs PicovoiceServiceArgs : PicovoiceService parameters.

PicovoiceService.keyword$

keyword$: Subject<string>

Subject which is updated when a keyword is detected.


PicovoiceService.inference$

inference$: Subject<RhinoInferenceFinalized>

Subject which is updated when an inference is finalized. See RhinoInferenceFinalized.


PicovoiceService.listening$

listening$: Subject<boolean>

Subject indicating whether the WebVoiceProcessor is passing audio to the engine.


PicovoiceService.isError$

isError$: Subject<boolean>

Subject which indicates that an error has occurred. Use error$ to retrieve the error object.


PicovoiceService.error$

error$: Subject<Error | string>

Subject which contains the error object when an error has occurred. Use isError$ to determine if content is present.


PicovoiceService.pause()

pause(): boolean

Pauses audio input from the WebVoiceProcessor and sets listening$ to false.

Returns

  • boolean : true if pause was successful.

PicovoiceService.start()

start(): boolean

Starts audio input from the WebVoiceProcessor and sets listening$ to true.

Returns

  • boolean : true if start was successful.

PicovoiceService.release()

async release(): Promise<void>

Releases resources acquired by the PicovoiceService and the WebVoiceProcessor.


PicovoiceServiceArgs

type PicovoiceServiceArgs = {
accessKey: string;
porcupineKeyword: PorcupineKeyword;
rhinoContext: RhinoContext;
requireEndpoint?: boolean;
start?: boolean;
};

Type alias for the PicovoiceService parameters.

Parameters

  • accessKey string : AccessKey obtained from Picovoice Console.
  • porcupineKeyword PorcupineKeyword : Keyword to use as a wake word. Can be either PorcupineKeywordBuiltin or PorcupineKeywordCustom.
  • rhinoContext RhinoContext : The context to use for intent.
  • requireEndpoint boolean : If set to true, Rhino requires an endpoint (chunk of silence) before finishing inference.
  • start? boolean : Optional. If set to true, the PicovoiceService 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.

PorcupineKeyword

type PorcupineKeyword = PorcupineKeywordCustom | PorcupineKeywordBuiltin;

Type alias for the Porcupine keywords which can be either PorcupineKeywordBuiltin or PorcupineKeywordCustom.


PorcupineKeywordBuiltin

type PorcupineKeywordBuiltin = {
builtin: string
sensitivity?: number
}

Type alias for the builtin keywords

Parameters

  • builtin string : Name of a builtin keyword for the specific language.
  • sensitivity? number : Optional. Value in range [0,1] that trades off miss rate for false alarm. If not set 0.5 will be used.

PorcupineKeywordCustom

type PorcupineKeywordCustom = {
base64: string
custom: string
sensitivity?: number
}

Type alias for the custom keywords

Parameters

  • base64 string : Base64 representation of a trained Porcupine keyword.
  • custom string : An arbitrary label that Picovoice reports when the detection occurs.
  • 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 RhinoInference = {
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.

Issue with this doc? Please let us know.