Picovoice Wordmark
Start Building
Introduction
Introduction
AndroidC.NETiOSLinuxmacOSNode.jsPythonRaspberry PiWebWindows
AndroidC.NETiOSNode.jsPythonWeb
SummaryPicovoice picoLLMGPTQ
Introduction
AndroidC.NETFlutteriOSJavaLinuxmacOSNode.jsPythonRaspberry PiReactReact NativeRustWebWindows
AndroidC.NETFlutteriOSJavaNode.jsPythonReactReact NativeRustWeb
SummaryPicovoice LeopardAmazon TranscribeAzure Speech-to-TextGoogle ASRGoogle ASR (Enhanced)IBM Watson Speech-to-TextWhisper Speech-to-Text
FAQ
Introduction
AndroidC.NETFlutteriOSJavaLinuxmacOSNode.jsPythonRaspberry PiReactReact NativeRustWebWindows
AndroidC.NETFlutteriOSJavaNode.jsPythonReactReact NativeRustWeb
SummaryPicovoice Cheetah
FAQ
Introduction
AndroidC.NETiOSLinuxmacOSNode.jsPythonRaspberry PiWebWindows
AndroidC.NETiOSNode.jsPythonWeb
SummaryAmazon PollyAzure TTSElevenLabsOpenAI TTSPicovoice Orca
Introduction
AndroidCiOSLinuxmacOSPythonRaspberry PiWebWindows
AndroidCiOSPythonWeb
SummaryPicovoice KoalaMozilla RNNoise
Introduction
AndroidCiOSLinuxmacOSNode.jsPythonRaspberry PiWebWindows
AndroidCNode.jsPythoniOSWeb
SummaryPicovoice EaglepyannoteSpeechBrainWeSpeaker
Introduction
AndroidCiOSLinuxmacOSPythonRaspberry PiWebWindows
AndroidCiOSPythonWeb
SummaryPicovoice FalconAmazon TranscribeAzure Speech-to-TextGoogle Speech-to-Textpyannote
Introduction
AndroidArduinoCChrome.NETEdgeFirefoxFlutteriOSJavaLinuxmacOSMicrocontrollerNode.jsPythonRaspberry PiReactReact NativeRustSafariUnityWebWindows
AndroidC.NETFlutteriOSJavaMicrocontrollerNode.jsPythonReactReact NativeRustUnityWeb
SummaryPorcupineSnowboyPocketSphinx
Wake Word TipsFAQ
Introduction
AndroidCChrome.NETEdgeFirefoxFlutteriOSJavaLinuxmacOSNode.jsPythonRaspberry PiReactReact NativeRustSafariUnityWebWindows
AndroidC.NETFlutteriOSJavaNode.jsPythonReactReact NativeRustUnityWeb
SummaryPicovoice RhinoGoogle DialogflowAmazon LexIBM WatsonMicrosoft LUIS
Expression SyntaxFAQ
Introduction
AndroidC.NETiOSLinuxmacOSNode.jsPythonRaspberry PiRustWebWindows
AndroidC.NETiOSNode.jsPythonRustWeb
SummaryPicovoice CobraWebRTC VAD
FAQ
Introduction
AndroidC.NETFlutteriOSNode.jsPythonReact NativeRustUnityWeb
AndroidC.NETFlutteriOSNode.jsPythonReact NativeRustUnityWeb
Introduction
C.NETNode.jsPython
C.NETNode.jsPython
FAQGlossary

Porcupine Wake Word
Web API

API Reference for the Porcupine Web SDK (npmjs).


Porcupine

class Porcupine {}

Class for the Porcupine Wake Word engine.


Porcupine.create()

public static async create(
accessKey: string,
keywords: Array<PorcupineKeyword | BuiltInKeyword> | PorcupineKeyword | BuiltInKeyword,
keywordDetectionCallback: DetectionCallback,
model: PorcupineModel,
options: PorcupineOptions = {},
): Promise<Porcupine>

Creates an instance of the Porcupine wake word engine using either a '.pv' file in public directory or a base64'd string. The model size is large, hence it will try to use the existing one if it exists, otherwise saves the model in storage.

Parameters

  • accessKey string : AccessKey obtained from Picovoice Console.
  • keywords Array<PorcupineKeyword | BuiltInKeyword> | PorcupineKeyword | BuiltInKeyword : Built-in or Base64 representations of keywords and their sensitivities. Can be provided as an array or a single keyword.
  • keywordDetectionCallback DetectionCallback : User-defined callback to run after a keyword is detected.
  • model PorcupineModel : object containing a base64 string representation of or path to public binary of a Porcupine parameter model used to initialize Porcupine.
  • options PorcupineOptions : Optional configuration arguments.

Returns

  • Porcupine : An instance of the Porcupine engine.

Porcupine.process()

public async process(pcm: Int16Array): Promise<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. Furthermore, the engine operates on single-channel audio.

The result will be supplied with the callback provided when initializing the engine.

Parameters

  • pcm Int16Array : A frame of audio.

Porcupine.release()

async function release(): Promise<void>

Releases resources acquired by the Porcupine Web SDK.


Porcupine.frameLength

get frameLength() : number

Number of audio samples per frame.


Porcupine.sampleRate

get sampleRate() : number

Audio sample rate accepted by Porcupine.


Porcupine.version

get version() : string

Porcupine version string.


DetectionCallback

type DetectionCallback = (detection: PorcupineDetection) => void;

Type defining the interface for the user-defined DetectionCallback used to run after a keyword is detected.

Parameters

  • detection PorcupineDetection : Detection data.

PorcupineModel

type PorcupineModel = {
base64?: string;
publicPath?: string;
customWritePath?: string;
forceWrite?: boolean;
version?: number;
};

Porcupine options type.

  • base64 string : Base64 representation of the file.
  • publicPath string : The file path relative to the public directory.
  • customWritePath string : Custom path to save the model in storage.
  • forceWrite boolean : Flag to overwrite the model in storage even if it exists.
  • version number : Porcupine model version. Set to a higher number to update the model file.

PorcupineOptions

type PorcupineOptions = {
processErrorCallback?: (error: string) => void;
};
  • 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 porcupine-web package.

PorcupineKeyword

type PorcupineKeyword = PorcupineKeywordCustom | PorcupineKeywordBuiltin;

Type that encapsulates PorcupineKeywordCustom and PorcupineKeywordBuiltin.


PorcupineKeywordCustom

type PorcupineKeywordCustom = {
label: string;
sensitivity?: number;
base64?: string;
publicPath?: string;
customWritePath?: string;
forceWrite?: boolean;
version?: number;
};

Type representing a keyword created using the Picovoice Console.

Parameters

  • label string : An arbitrary label used for caching purposes
  • sensitivity number : Sensitivity value for detecting the keyword. Value should be a number within [0, 1]. A higher sensitivity results in fewer misses at the cost of increasing the false alarm rate. The default value is 0.5.
  • base64 string : Base64 representation of the file.
  • publicPath string : The file path relative to the public directory.
  • customWritePath string : Custom path to save the model in storage.
  • forceWrite boolean : Flag to overwrite the model in storage even if it exists.
  • version number : Porcupine model version. Set to a higher number to update the model file.

PorcupineKeywordBuiltin

type PorcupineKeywordBuiltin = {
builtin: BuiltInKeyword;
sensitivity?: number;
};

Type representing a pre-trained keyword that is included with the Porcupine Web SDK.

Parameters

  • builtin BuiltInKeyword : Name of a built-in keyword
  • sensitivity number : Sensitivity value for detecting the keyword. Value should be a number within [0, 1]. A higher sensitivity results in fewer misses at the cost of increasing the false alarm rate. The default value is 0.5.

PorcupineDetection

type PorcupineDetection = {
index: number;
label: string;
}

Type containing detection result data returned from the Porcupine engine.

Parameters

  • index number : The index of the detected keyword.
  • label string : The corresponding label of the detected keyword.

PorcupineWorker

class PorcupineWorker {}

A class for using Porcupine on a worker thread.


PorcupineWorker.create()

public static async create(
accessKey: string,
keywords: Array<PorcupineKeyword | BuiltInKeyword> | PorcupineKeyword | BuiltInKeyword,
keywordDetectionCallback: DetectionCallback,
model: PorcupineModel,
options: PorcupineOptions = {},
): Promise<PorcupineWorker>

Creates an instance of the PorcupineWorker using either a '.pv' file in public directory or a base64'd string. The model size is large, hence it will try to use the existing one if it exists, otherwise saves the model in storage.

Parameters

  • accessKey string : AccessKey obtained from Picovoice Console.
  • keywords Array<PorcupineKeyword | BuiltInKeyword> | PorcupineKeyword | BuiltInKeyword : Built-in or Base64 representations of keywords and their sensitivities. Can be provided as an array or a single keyword.
  • keywordDetectionCallback DetectionCallback : User-defined callback to run after a keyword is detected.
  • model PorcupineModel : object containing a base64 string representation of or path to public binary of a Porcupine parameter model used to initialize Porcupine.
  • options PorcupineOptions : Optional configuration arguments.

Returns

  • PorcupineWorker : An instance of PorcupineWorker.

PorcupineWorker.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. Furthermore, the engine operates on single-channel audio.

The result will be supplied with the callback provided when creating the worker.

Parameters

  • pcm Int16Array : A frame of audio.

PorcupineWorker.release()

async function release(): Promise<void>

Releases resources acquired by the Porcupine Web SDK.


PorcupineWorker.terminate()

async function terminate(): Promise<void>

Force terminates the instance of PorcupineWorker.


PorcupineWorker.frameLength

get frameLength : number

Number of audio samples per frame.


PorcupineWorker.sampleRate

get sampleRate : number

Audio sample rate accepted by Porcupine.


PorcupineWorker.version

get version : string

Porcupine version string.


BuiltInKeyword

enum BuiltInKeyword {
Alexa = 'Alexa',
Americano = 'Americano',
Blueberry = 'Blueberry',
Bumblebee = 'Bumblebee',
Computer = 'Computer',
Grapefruit = 'Grapefruit',
Grasshopper = 'Grasshopper',
HeyGoogle = 'Hey Google',
HeySiri = 'Hey Siri',
Jarvis = 'Jarvis',
OkayGoogle = 'Okay Google',
Picovoice = 'Picovoice',
Porcupine = 'Porcupine',
Terminator = 'Terminator',
}

Enum of built-in keywords.


PorcupineError

class PorcupineError extends Error { }

Error thrown if an error occurs within Porcupine wake word engine.

Errors:

class PorcupineActivationError extends PorcupineError { }
class PorcupineActivationLimitError extends PorcupineError { }
class PorcupineActivationRefusedError extends PorcupineError { }
class PorcupineActivationThrottledError extends PorcupineError { }
class PorcupineIOError extends PorcupineError { }
class PorcupineInvalidArgumentError extends PorcupineError { }
class PorcupineInvalidStateError extends PorcupineError { }
class PorcupineKeyError extends PorcupineError { }
class PorcupineMemoryError extends PorcupineError { }
class PorcupineRuntimeError extends PorcupineError { }
class PorcupineStopIterationError extends PorcupineError { }

Was this doc helpful?

Issue with this doc?

Report a GitHub Issue
Porcupine Wake Word Web API
  • Porcupine
  • create()
  • process()
  • release()
  • frameLength
  • sampleRate
  • version
  • DetectionCallback
  • PorcupineModel
  • PorcupineOptions
  • PorcupineKeyword
  • PorcupineKeywordCustom
  • PorcupineKeywordBuiltin
  • PorcupineDetection
  • PorcupineWorker
  • create()
  • process()
  • release()
  • terminate()
  • frameLength
  • sampleRate
  • version
  • BuiltInKeyword
  • PorcupineError
Voice AI
  • Leopard Speech-to-Text
  • Cheetah Streaming Speech-to-Text
  • Orca Text-to-Speech
  • Koala Noise Suppression
  • Eagle Speaker Recognition
  • Falcon Speaker Diarization
  • Porcupine Wake Word
  • Rhino Speech-to-Intent
  • Cobra Voice Activity Detection
Local LLM
  • picoLLM Inference
  • picoLLM Compression
  • picoLLM GYM
Resources
  • Docs
  • Console
  • Blog
  • Use Cases
  • Playground
Sales & Services
  • Consulting
  • Foundation Plan
  • Enterprise Plan
  • Enterprise Support
Company
  • About us
  • Careers
Follow Picovoice
  • LinkedIn
  • GitHub
  • X
  • YouTube
  • AngelList
Subscribe to our newsletter
Terms of Use
Privacy Policy
© 2019-2025 Picovoice Inc.