angularPorcupine - Angular API

API Reference for the Porcupine Angular SDK (npm).


PorcupineService

class PorcupineService implements OnDestroy { }

Angular service for Porcupine wake word engine.


PorcupineService.init()

async init(
porcupineWorkerFactory: PorcupineWorkerFactory,
porcupineServiceArgs: PorcupineServiceArgs
): Promise<void>

Initializes the PorcupineService. Subscribe to the keyword$ subject to receive keyword detection events.

Parameters

  • porcupineWorkerFactory PorcupineWorkerFactory : The language-specific worker factory, imported as { PorcupineWorkerFactory } from the @picovoice/porcupine-web-xx-worker series of packages, where xx is the two-letter language code.
  • porcupineServiceArgs PorcupineServiceArgs : PorcupineService parameters.

PorcupineService.keyword$

keyword$: Subject<string>

Subject which is updated when a keyword is detected.


PorcupineService.listening$

listening$: Subject<boolean>

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


PorcupineService.isError$

isError$: Subject<boolean>

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


PorcupineService.error$

error$: Subject<Error | string>

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


PorcupineService.pause()

pause(): boolean

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

Returns

  • boolean : true if pause was successful.

PorcupineService.start()

start(): boolean

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

Returns

  • boolean : true if start was successful.

PorcupineService.release()

async release(): Promise<void>

Releases resources acquired by the PorcupineService and the WebVoiceProcessor.


PorcupineServiceArgs

type PorcupineServiceArgs = {
start?: boolean
accessKey: string
keywords: Array<PorcupineKeyword | string> | PorcupineKeyword | string
}

Type alias for the PorcupineService parameters.

Parameters

  • start? boolean : Optional. If set to true, the PorcupineService immediately starts the microphone upon initialization.
  • accessKey string : AccessKey obtained from Picovoice Console.
  • keywords Array<PorcupineKeyword | string> : An array of keywords to listen for. Keywords can be either PorcupineKeywordBuiltin or PorcupineKeywordCustom.

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.

Issue with this doc? Please let us know.