wasmPicovoice - Web API

API Reference for the Picovoice Web SDK.


Picovoice

class Picovoice implements PicovoiceEngine

Class for the Picovoice Platform.


Picovoice.create()

static async function create(picovoiceArgs: PicovoiceEngineArgs): Promise<Picovoice>

Creates an instance of the Picovoice Platform.

Parameters

Returns

  • Picovoice : An instance of the Picovoice platform.

Picovoice.process()

async function process(pcm: Int16Array): Promise<void>

Processes a frame of audio and invokes user-provided callbacks if the keyword is detected or an intent is inferred. The required sample rate can be retrieved from 'sampleRate' and the length of frame (number of audio samples per frame) can be retrieved from 'frameLength'. The audio must be single-channel and 16-bit linearly-encoded.

Parameters

  • pcm Int16Array : A frame of audio.

Picovoice.release()

async function release(): Promise<void>

Releases resources acquired by the Picovoice Web SDK.


Picovoice.contextInfo

get contextInfo(): string

Stores the source of the Rhino context in YAML format. Shows the list of intents, which expressions map to those intents, as well as slots and their possible values.


Picovoice.frameLength

get frameLength(): number

Number of audio samples per frame.


Picovoice.paused

set paused(pause: boolean)
get paused(): boolean

Indicates if Picovoice will process incoming audio.


Picovoice.sampleRate

get sampleRate(): number

Audio sample rate accepted by Picovoice.


Picovoice.version

get version(): string

Picovoice version string.


PicovoiceEngineArgs

export type PicovoiceEngineArgs = {
accessKey: string
porcupineKeyword: PorcupineKeyword
rhinoContext: RhinoContext
porcupineCallback: (keywordLabel: string) => void
rhinoCallback: (inference: RhinoInference) => void
requireEndpoint?: boolean
}

Type which contains the input arguments to create an instance of Picovoice.

  • accessKey string : AccessKey obtained from Picovoice Console.
  • porcupineKeyword PorcupineKeyword : Object containing Porcupine keyword data.
  • rhinoContext RhinoContext : Object containing Rhino context data.
  • porcupineCallback (keywordLabel: string) => void : Callback that is invoked when Porcupine detects the wake word.
  • rhinoCallback (inference: RhinoInference) => void : Callback that is invoked when Rhino made an intent inference.
  • requireEndpoint boolean : If set to false, Rhino does not require an endpoint (chunk of silence) before finishing an inference. Default value is true.

PicovoiceWorker

export interface PicovoiceWorker extends Omit<Worker, 'postMessage'>

Interface for the Picovoice web worker.


PicovoiceWorkerArgs

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

Type which contains the input arguments to create an instance of the PicovoiceWorker.

  • accessKey string : AccessKey obtained from Picovoice Console.
  • porcupineKeyword PorcupineKeyword : Object containing Porcupine keyword data.
  • rhinoContext RhinoContext : Object containing Rhino context data.
  • requireEndpoint boolean : If set to false, Rhino does not require an endpoint (chunk of silence) before finishing an inference. Default value is true.
  • start boolean : Indicates if worker should begin accepting audio as soon as it's initialized.

PicovoiceWorkerFactory

class PicovoiceWorkerFactory

A factory class for creating new instances of the PicovoiceWorker web worker.


PicovoiceWorkerFactory.create()

static async function create(picovoiceArgs: PicovoiceWorkerArgs): Promise<PicovoiceWorker>

Creates Picovoice web worker instances. The promise resolves when the worker is ready to process voice data.

Parameters

Returns


Issue with this doc? Please let us know.