Picovoice WordmarkPicovoice Console
Introduction
Introduction
AndroidC.NETFlutterlink to GoiOSJavaNvidia JetsonLinuxmacOSNodejsPythonRaspberry PiReact NativeRustWebWindows
AndroidC.NETFlutterlink to GoiOSJavaNodejsPythonReact NativeRustWeb
SummaryPicovoice LeopardAmazon TranscribeAzure Speech-to-TextGoogle ASRGoogle ASR (Enhanced)IBM Watson Speech-to-Text
FAQ
Introduction
AndroidC.NETFlutterlink to GoiOSJavaNodejsPythonReact NativeRustWeb
AndroidC.NETFlutterlink to GoiOSJavaNodejsPythonReact NativeRustWeb
FAQ
Introduction
AndroidCiOSLinuxmacOSPythonWebWindows
AndroidCiOSPythonWeb
SummaryOctopus Speech-to-IndexGoogle Speech-to-TextMozilla DeepSpeech
FAQ
Introduction
AndroidAngularArduinoBeagleBoneCChrome.NETEdgeFirefoxFlutterlink to GoiOSJavaNvidia JetsonLinuxmacOSMicrocontrollerNodejsPythonRaspberry PiReactReact NativeRustSafariUnityVueWebWindows
AndroidAngularC.NETFlutterlink to GoiOSJavaMicrocontrollerNodejsPythonReactReact NativeRustUnityVueWeb
SummaryPorcupineSnowboyPocketSphinx
Wake Word TipsFAQ
Introduction
AndroidAngularBeagleBoneCChrome.NETEdgeFirefoxFlutterlink to GoiOSJavaNvidia JetsonlinuxmacOSNodejsPythonRaspberry PiReactReact NativeRustSafariUnityVueWebWindows
AndroidAngularC.NETFlutterlink to GoiOSJavaNodejsPythonReactReact NativeRustUnityVueWeb
SummaryPicovoice RhinoGoogle DialogflowAmazon LexIBM WatsonMicrosoft LUIS
Expression SyntaxFAQ
Introduction
AndroidBeagleboneCiOSNvidia JetsonLinuxmacOSPythonRaspberry PiRustWebWindows
AndroidCiOSPythonRustWeb
SummaryPicovoice CobraWebRTC VAD
FAQ
Introduction
AndroidAngularArduinoBeagleBoneC.NETFlutterlink to GoiOSJavaNvidia JetsonMicrocontrollerNodejsPythonRaspberry PiReactReact NativeRustUnityVueWeb
AndroidAngularCMicrocontroller.NETFlutterlink to GoiOSJavaNodejsPythonReactReact NativeRustUnityVueWeb
Picovoice SDK - FAQ
IntroductionSTM32F407G-DISC1 (Arm Cortex-M4)STM32F411E-DISCO (Arm Cortex-M4)STM32F769I-DISCO (Arm Cortex-M7)IMXRT1050-EVKB (Arm Cortex-M7)
FAQGlossary

Picovoice Platform — Web API


API Reference for the Picovoice Web SDK (npmjs).


Picovoice

class Picovoice {}

Class for using Picovoice Platform on the main thread.


Picovoice.create()

static async function create(
accessKey: string,
keyword: PorcupineKeyword,
wakeWordCallback: DetectionCallback,
porcupineModel: PorcupineModel,
context: RhinoContext,
inferenceCallback: InferenceCallback,
rhinoModel: RhinoModel,
options: PicovoiceOptions = {}
): Promise<Picovoice>

Creates an instance of Picovoice.

Parameters

  • accessKey string : AccessKey obtained from Picovoice Console.
  • keyword PorcupineKeyword : A Porcupine keyword. Can be provided as a built-in, base64 or a hosted .ppn file.
  • wakeWordCallback DetectionCallback : User-defined callback to run after a keyword is detected.
  • porcupineModel PorcupineModel : Contains the model parameters that are used to initialize the Porcupine engine. Model can be encoded in base64 or can be stored in a .pv file in a public directory.
  • context RhinoContext : A Rhino context. Can be provided as a base64 or a hosted .rhn file.
  • inferenceCallback InferenceCallback : User-defined callback invoked when Rhino has made an inference.
  • rhinoModel RhinoModel : Contains the model parameters that are used to initialize the Rhino engine. Model can be encoded in base64 or can be stored in a .pv file in a public directory.
  • options PicovoiceOptions : Optional configuration arguments.

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.

Results are returned via the user-defined wakeWordCallback and inferenceCallback provided when creating Picovoice.

Parameters

  • pcm Int16Array : A frame of audio.

Picovoice.reset()

async function reset(): Promise<void>

Resets the internal Picovoice state.


Picovoice.release()

async function release(): Promise<void>

Releases resources acquired by the Picovoice Web SDK.


Picovoice.contextInfo

get contextInfo() : string | undefined

Get the Rhino context info. Shows the list of intents, which expressions map to those intents, as well as slots and their possible values.


Picovoice.frameLength

get frameLength() : number | undefined

Get number of samples per frame required by Picovoice.


Picovoice.sampleRate

get sampleRate() : number | undefined

Get audio sample rate required by Picovoice.


Picovoice.version

get version() : string

Get Picovoice SDK version.


PicovoiceOptions

type PicovoiceOptions = {
processErrorCallback?: (error: string) => void;
/** @defaultValue '1.0' */
endpointDurationSec?: number;
/** @defaultValue 'false' */
requireEndpoint?: boolean;
};

Optional parameters for Picovoice.

  • processErrorCallback (error: string) => void : User-defined callback invoked if any error happens while processing the audio stream. Its only input argument is the error message. NOTE: This is only used by the picovoice-web package.
  • endpointDurationSec number : Endpoint duration in seconds. An endpoint is a chunk of silence at the end of an utterance that marks the end of spoken command. It should be a positive number within [0.5, 5]. A lower endpoint duration reduces delay and improves responsiveness. A higher endpoint duration assures Rhino doesn't return inference pre-emptively in case the user pauses before finishing the request.
  • requireEndpoint If set to true, Rhino requires an endpoint (a chunk of silence) after the spoken command. If set to false, Rhino tries to detect silence, but if it cannot, it still will provide inference regardless. Set to false only if operating in an environment with overlapping speech (e.g. people talking in the background).

PicovoiceWorker

class PicovoiceWorker {}

A class for using Picovoice Platform on a worker thread.


PicovoiceWorker.create()

static async function create(
accessKey: string,
keyword: PorcupineKeyword,
wakeWordCallback: DetectionCallback,
porcupineModel: PorcupineModel,
context: RhinoContext,
inferenceCallback: InferenceCallback,
rhinoModel: RhinoModel,
options: PicovoiceOptions = {}
): Promise<PicovoiceWorker>

Creates an instance of PicovoiceWorker.

Parameters

  • accessKey string : AccessKey obtained from Picovoice Console.
  • keyword PorcupineKeyword : A Porcupine keyword. Can be provided as a built-in, base64 or a hosted .ppn file.
  • wakeWordCallback DetectionCallback : User-defined callback to run after a keyword is detected.
  • porcupineModel PorcupineModel : Contains the model parameters that are used to initialize the Porcupine engine. Model can be encoded in base64 or can be stored in a .pv file in a public directory.
  • context RhinoContext : A Rhino context. Can be provided as a base64 or a hosted .rhn file.
  • inferenceCallback InferenceCallback : User-defined callback invoked when Rhino has made an inference.
  • rhinoModel RhinoModel : Contains the model parameters that are used to initialize the Rhino engine. Model can be encoded in base64 or can be stored in a .pv file in a public directory.
  • options PicovoiceOptions : Optional configuration arguments.

Returns

  • PicovoiceWorker : An instance of the Picovoice platform on a worker thread.

PicovoiceWorker.process()

async function process(pcm: Int16Array): void

Processes a frame of audio. 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 needs to be 16-bit linearly-encoded. Picovoice operates on single-channel audio.

Results are returned via the user-defined wakeWordCallback and inferenceCallback that are provided when creating a PicovoiceWorker.

Parameters

  • pcm Int16Array : A frame of audio.

PicovoiceWorker.reset()

async function reset(): void

Resets the internal Picovoice state.


PicovoiceWorker.release()

async function release(): Promise<void>

Releases resources acquired by the Picovoice Web SDK.


PicovoiceWorker.terminate()

async function terminate(): void

Force terminates the instance of PicovoiceWorker.


PicovoiceWorker.contextInfo

get contextInfo() : string | undefined

Get the Rhino context info. Shows the list of intents, which expressions map to those intents, as well as slots and their possible values.


PicovoiceWorker.frameLength

get frameLength() : number | undefined

Get number of samples per frame required by Picovoice.


PicovoiceWorker.sampleRate

get sampleRate() : number | undefined

Get audio sample rate required by Picovoice.


PicovoiceWorker.version

get version() : string

Get Picovoice SDK version.

Was this doc helpful?

Issue with this doc?

Report a GitHub Issue
Picovoice Platform — Web API
  • Picovoice
  • create()
  • process()
  • reset()
  • release()
  • contextInfo
  • frameLength
  • sampleRate
  • version
  • PicovoiceOptions
  • PicovoiceWorker
  • create()
  • process()
  • reset()
  • release()
  • terminate()
  • contextInfo
  • frameLength
  • sampleRate
  • version
Platform
  • Leopard Speech-to-Text
  • Cheetah Streaming Speech-to-Text
  • Octopus Speech-to-Index
  • Porcupine Wake Word
  • Rhino Speech-to-Intent
  • Cobra Voice Activity Detection
Resources
  • Docs
  • Console
  • Blog
  • Demos
Sales
  • Pricing
  • Starter Tier
  • Enterprise
Company
  • Careers
Follow Picovoice
  • LinkedIn
  • GitHub
  • Twitter
  • Medium
  • YouTube
  • AngelList
Subscribe to our newsletter
Terms of Use
Privacy Policy
© 2019-2022 Picovoice Inc.