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

Porcupine Wake Word — Web API


API Reference for the Porcupine Web SDK.


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.

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
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.