vuePicovoice SDK - Vue API

API Reference for the Picovoice Vue SDK.


$picovoice

Vue mixin for Picovoice SDK.


$picovoice.init()

async function init(
picovoiceFactoryArgs: PicovoiceWorkerFactoryArgs,
picovoiceFactory: PicovoiceWorkerFactory,
keywordCallback: (label: string) => void,
inferenceCallback: (inference: RhinoInferenceFinalized) => void,
contextCallback: (info: string) => void,
readyCallback: () => void,
errorCallback: (error: Error) => void
): void

Initializes PicovoiceWorkerFactory based on arguments PicovoiceWorkerFactoryArgs and the language-specific worker factory.

Parameters

  • picovoiceFactoryArgs PicovoiceWorkerFactoryArgs : Arguments for PicovoiceWorkerFactory.
  • picovoiceFactory 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.
  • keywordCallback (string) => void : A method invoked upon detection of the keywords.
  • inferenceCallback ([RhinoInferenceFinalized](#rhinoinferencefinalized)) => void : A method invoked upon completion of intent inference.
  • contextCallback (string) => void : A method invoked after Picovoice has initialized and has context information.
  • readyCallback () => void : A method invoked after Picovoice has initialized.
  • errorCallback (Error) => void : A method invoked if an error occurs within PicovoiceWorkerFactory.

$picovoice.start()

function start(): boolean

Method to start processing audio.

Returns

  • boolean: True if successfully started.

$picovoice.pause()

function pause(): boolean

Method to stop processing audio.

Returns

  • boolean: True if successfully stopped.

$picovoice.delete()

function delete(): void

Method to release resources used by Picovoice.


PicovoiceWorkerFactoryArgs

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

Type alias for PicovoiceWorkerFactory arguments.

Parameters

  • accessKey string : AccessKey obtained from Picovoice Console.
  • porcupineKeyword PorcupineKeyword : The keyword to listen for.
  • rhinoContext RhinoContext : The context to instantiate.
  • requireEndpoint boolean : Optional. If set to true, Rhino requires an endpoint (chunk of silence) before finishing inference.
  • start boolean : Optional. If set to true, Picovoice 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 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.

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 RhinoInference = {
isFinalized: boolean
isUnderstood?: boolean
intent?: string
slots?: {[key: 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 {[string]: string} : Map of the slot variables and values extracted from the utterance.

EngineControlType

type EngineControlType = 'ppn' | 'rhn'

Type alias for the active engine.


PicovoiceVue

interface PicovoiceVue {
$_ppnWorker_: Worker | null;
$_webVp_: WebVoiceProcessor | null;
init: (
picovoiceFactoryArgs: PicovoiceWorkerFactoryArgs,
picovoiceFactory: PicovoiceWorkerFactory,
keywordCallback: (label: string) => void,
inferenceCallback: (inference: RhinoInferenceFinalized) => void,
contextCallback: (info: string) => void,
readyCallback: () => void,
errorCallback: (error: Error) => void): void;
start: () => boolean;
pause: () => boolean;
delete: () => void;
}

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

Parameters


Issue with this doc? Please let us know.