vuePorcupine - Vue API

API Reference for the Porcupine Vue SDK.


$porcupine

Vue mixin for Porcupine Wake Word engine.


$porcupine.init()

async function init(
porcupineFactoryArgs: PorcupineWorkerFactoryArgs,
porcupineFactory: PorcupineWorkerFactory,
keywordCallback: (label: string) => void,
readyCallback: () => void,
errorCallback: (error: Error) => void
): void

Initializes PorcupineWorker instance based on arguments PorcupineWorkerFactoryArgs and the language-specific worker factory.

Parameters

  • porcupineFactoryArgs PorcupineWorkerFactoryArgs : Arguments for PorcupineWorkerFactory.
  • porcupineFactory 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.
  • keywordCallback (string) => void : A method invoked upon detection of the keywords.
  • readyCallback () => void : A method invoked after Porcupine has initialized.
  • errorCallback (Error) => void : A method invoked if an error occurs within PorcupineWorkerFactory.

$porcupine.start()

function start(): boolean

Method to start processing audio.

Returns

  • boolean: True if successfully started.

$porcupine.pause()

function pause(): boolean

Method to stop processing audio.

Returns

  • boolean: True if successfully stopped.

$porcupine.delete()

function delete(): void

Method to release resources used by Porcupine.


PorcupineWorkerFactory

interface PorcupineWorkerFactory extends Object {
create: (
accessKey: string,
keywords: Array<PorcupineKeyword | string> | PorcupineKeyword | string,
keywordDetectionCallback?: CallableFunction,
processErrorCallback?: CallableFunction,
start?: boolean) => Promise<Worker>,
};

Type alias for PorcupineWorkerFactory arguments.

Parameters

  • accessKey string : AccessKey obtained from Picovoice Console.
  • keywords Array<PorcupineKeyword | string> | PorcupineKeyword | string : Keywords to listen for.
  • keywordDetectionCallback CallableFunction : A method invoked upon detecting any keyword.
  • processErrorCallback CallableFunction : A method invoked if an error occurs while initializing PorcupineWorkerFactory.
  • start boolean : Optional. If set to true, Porcupine immediately starts the microphone upon initialization.

PorcupineWorkerFactoryArgs

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

Type alias for PorcupineWorkerFactory arguments.

Parameters

  • accessKey string : AccessKey obtained from Picovoice Console.
  • keywords Array<PorcupineKeyword | string> | PorcupineKeyword | string : Keywords to listen for.
  • start boolean : Optional. If set to true, Porcupine immediately starts the microphone upon initialization.

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 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 custom keywords.

Parameters

  • base64 string : Base64 representation of a trained Porcupine keyword.
  • custom string : An arbitrary label that Porcupine 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.

PorcupineVue

interface PorcupineVue {
$_ppnWorker_: Worker | null;
$_webVp_: WebVoiceProcessor | null;
init: (
porcupineFactoryArgs: PorcupineWorkerFactoryArgs,
porcupineFactory: PorcupineWorkerFactory,
keywordCallback: (label: string) => void,
readyCallback: () => void,
errorCallback: (error: Error) => void): void;
start: () => boolean;
pause: () => boolean;
delete: () => void;
}

Type alias for Porcupine Vue Mixin. Import and extend Vue interface with PorcupineVue in order to get types while using typescript.

Parameters


Issue with this doc? Please let us know.