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

Cobra Voice Activity Detection
Web API

API Reference for the Cobra Web SDK (npm).


Cobra

class Cobra {}

Class for the Cobra VAD engine.


Cobra.create()

static async function create(
accessKey: string,
voiceProbabilityCallback: (voiceProbability: number) => void,
options: CobraOptions = {}
): Promise<Cobra>

Creates an instance of the Cobra voice activity detection (VAD) engine.

Parameters

  • accessKey string : AccessKey obtained from Picovoice Console.
  • voiceProbabilityCallback (voiceProbability: number) => void : User-defined callback invoked when a frame of audio is processed. The callback provides a single parameter 'voiceProbability': a floating-point number within [0, 1].
  • options CobraOptions : Optional configuration arguments.

Returns

  • Cobra : An instance of the Cobra engine.

Cobra.process()

async function 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 must be single-channel and 16-bit linearly-encoded.

The voice probability result will be supplied via the voiceProbabilityCallback that was passed into Cobra.create().

Parameters

  • pcm Int16Array : A frame of audio samples.

Cobra.release()

async function release(): Promise<void>

Releases resources acquired by the Cobra Web SDK.


Cobra.frameLength

get framelength(): number

Number of audio samples per frame.


Cobra.sampleRate

get sampleRate(): number

Audio sample rate accepted by Cobra.


Cobra.version

get version(): string

Cobra version string.


CobraOptions

type CheetahOptions = {
processErrorCallback?: (error: string) => void
}

Cobra options type.

  • processErrorCallback boolean : 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 CobraWorker.

CobraWorker

class CobraWorker {}

A class for running the Cobra VAD engine as a web worker thread.


CobraWorker.create()

static async function create(
accessKey: string,
voiceProbabilityCallback: (voiceProbability: number) => void,
options: CobraOptions = {}
): Promise<CobraWorker>

Creates an instance of CobraWorker.

Parameters

  • accessKey string : AccessKey obtained from Picovoice Console.
  • voiceProbabilityCallback (voiceProbability: number) => void : User-defined callback invoked when a frame of audio is processed. The callback provides a single parameter 'voiceProbability': a floating-point number within [0, 1].
  • options CobraOptions : Optional configuration arguments.

Returns

  • CobraWorker : An instance of CobraWorker.

CobraWorker.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 must be single-channel and 16-bit linearly-encoded.

The voice probability result will be supplied via the voiceProbabilityCallback that was passed into CobraWorker.create().

Parameters

  • pcm Int16Array : A frame of audio samples.

CobraWorker.release()

async function release(): Promise<void>

Releases resources acquired by the Cobra Web SDK.


CobraWorker.terminate()

async function terminate(): Promise<void>

Force terminates the instance of CobraWorker.


CobraWorker.frameLength

get frameLength(): number

Number of audio samples per frame.


CobraWorker.sampleRate

get sampleRate(): number

Audio sample rate accepted by Cobra.


CobraWorker.version

get version(): string

Cobra version string.


CobraError

class CobraError extends Error { }

Error thrown if an error occurs within Cobra VAD engine.

Errors:

class CobraActivationError extends CobraError { }
class CobraActivationLimitError extends CobraError { }
class CobraActivationRefusedError extends CobraError { }
class CobraActivationThrottledError extends CobraError { }
class CobraIOError extends CobraError { }
class CobraInvalidArgumentError extends CobraError { }
class CobraInvalidStateError extends CobraError { }
class CobraKeyError extends CobraError { }
class CobraMemoryError extends CobraError { }
class CobraRuntimeError extends CobraError { }
class CobraStopIterationError extends CobraError { }

Was this doc helpful?

Issue with this doc?

Report a GitHub Issue
Cobra Voice Activity Detection Web API
  • Cobra
  • create()
  • process()
  • release()
  • frameLength
  • sampleRate
  • version
  • CobraOptions
  • CobraWorker
  • create()
  • process()
  • release()
  • terminate()
  • frameLength
  • sampleRate
  • version
  • CobraError
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.