Picovoice 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 forPicovoiceWorkerFactory
.picovoiceFactory
PicovoiceWorkerFactory: The language-specific worker factory, imported as{ PicovoiceWorkerFactory }
from the@picovoice/picovoice-web-xx-worker
series of packages, wherexx
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 afterPicovoice
has initialized and has context information.readyCallback
() => void : A method invoked afterPicovoice
has initialized.errorCallback
(Error) => void : A method invoked if an error occurs withinPicovoiceWorkerFactory
.
$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: stringporcupineKeyword: PorcupineKeywordrhinoContext: RhinoContextrequireEndpoint?: booleanstart?: 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 totrue
, Rhino requires an endpoint (chunk of silence) before finishing inference.start
boolean : Optional. If set totrue
, 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: stringsensitivity?: 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: stringcustom: stringsensitivity?: 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: stringsensitivity?: 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: booleanisUnderstood?: booleanintent?: stringslots?: {[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
$_pvWorker_
Worker | null : The worker instance ofPicovoice
.$_webVp_
WebVoiceProcessor | null : Web Voice Processor instance to record audio.init
$picovoice.init : Picovoice init function.start
$picovoice.start : Picovoice start function.pause
$picovoice.pause : Picovoice pause function.delete
$picovoice.delete : Picovoice delete function.