Picovoice Wordmark
Start Free
Introduction
Introduction
AndroidC.NETiOSLinuxmacOSNode.jsPythonRaspberry PiWebWindows
AndroidC.NETiOSNode.jsPythonWeb
SummaryPicovoice picoLLMGPTQ
Introduction
AndroidCiOSLinuxmacOSPythonRaspberry PiWebWindows
AndroidCiOSPythonWeb
Introduction
AndroidC.NETFlutteriOSJavaLinuxmacOSNode.jsPythonRaspberry PiReactReact NativeWebWindows
AndroidC.NETFlutteriOSJavaNode.jsPythonReactReact NativeWeb
SummaryPicovoice LeopardAmazon TranscribeAzure Speech-to-TextGoogle ASRGoogle ASR (Enhanced)IBM Watson Speech-to-TextWhisper Speech-to-Text
FAQ
Introduction
AndroidC.NETFlutteriOSJavaLinuxmacOSNode.jsPythonRaspberry PiReactReact NativeWebWindows
AndroidC.NETFlutteriOSJavaNode.jsPythonReactReact NativeWeb
SummaryPicovoice CheetahAzure Real-Time Speech-to-TextAmazon Transcribe StreamingGoogle Streaming ASRMoonshine StreamingVosk StreamingWhisper.cpp Streaming
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 NativeSafariWebWindows
AndroidC.NETFlutteriOSJavaMicrocontrollerNode.jsPythonReactReact NativeWeb
SummaryPicovoice PorcupineSnowboyPocketSphinx
Wake Word TipsFAQ
Introduction
AndroidArduinoCChrome.NETEdgeFirefoxFlutteriOSJavaLinuxmacOSMicrocontrollerNode.jsPythonRaspberry PiReactReact NativeSafariWebWindows
AndroidC.NETFlutteriOSJavaMicrocontrollerNode.jsPythonReactReact NativeWeb
SummaryPicovoice RhinoGoogle DialogflowAmazon LexIBM WatsonMicrosoft LUIS
Expression SyntaxFAQ
Introduction
AndroidArduinoC.NETiOSLinuxmacOSMicrocontrollerNode.jsPythonRaspberry PiWebWindows
AndroidC.NETiOSMicrocontrollerNode.jsPythonWeb
SummaryPicovoice CobraWebRTC VADSilero VAD
FAQ
Introduction
AndroidCiOSLinuxmacOSPythonRaspberry PiWebWindows
AndroidCiOSPythonWeb
Introduction
AndroidC.NETFlutteriOSNode.jsPythonReact NativeWeb
AndroidC.NETFlutteriOSNode.jsPythonReact NativeWeb
Introduction
C.NETNode.jsPython
C.NETNode.jsPython
FAQGlossary

Bat Spoken Language Identification
Web API

API Reference for the Bat Web SDK (npm).


Bat

class Bat {}

Class for the Bat Spoken Language Identification engine.


Bat.create()

static async function create(
accessKey: string,
scoresCallback: (scores: BatScores | null) => void,
model: BatModel,
options: BatOptions = {}
): Promise<Bat>

Creates an instance of the Bat Spoken Language Identification engine.

Parameters

  • accessKey string : AccessKey obtained from Picovoice Console.
  • scoresCallback (scores: BatScores | null) => void : User-defined callback to run after receiving scores result.
  • model BatModel : Bat model options.
  • options BatOptions : Optional configuration arguments.

Returns

  • Bat : An instance of the Bat engine.

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

Language identification scores are returned via the scoresCallback defined during init.

Parameters

  • pcm Int16Array : A frame of audio samples.

Bat.release()

async function release(): Promise<void>

Releases resources acquired by the Bat Web SDK.


Bat.frameLength

get framelength(): number

Number of audio samples per frame.


Bat.sampleRate

get sampleRate(): number

Audio sample rate accepted by Bat.


Bat.version

get version(): string

Bat version string.


Bat.listAvailableDevices()

public static async listAvailableDevices(): Promise<string[]>

Lists all available devices that Bat can use for inference. Each entry in the list can be the used as the device argument for the .create() method.

Returns

  • string[] : List of all available devices that Bat can use for inference.

BatModel

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

Bat model type.

  • base64 string: The model file (.pv) in base64 string to initialize Bat.
  • publicPath string: The model file (.pv) path relative to the public directory.
  • customWritePath string : Custom path to save the model in storage. Set to a different name to use multiple models across bat instances.
  • forceWrite boolean : Flag to overwrite the model in storage even if it exists.
  • version number : Version of the model file. Increment to update the model file in storage.

BatOptions

type BatOptions = {
device?: string;
voiceThreshold?: number;
processErrorCallback?: (error: string) => void
}

Bat options type.

  • device string : Optional. String representation of the device (e.g., CPU or GPU) to use. If set to best, the most suitable device is selected automatically. If set to gpu, the engine uses the first available GPU device. To select a specific GPU device, set this argument to gpu:${GPU_INDEX}, where ${GPU_INDEX} is the index of the target GPU. If set to cpu, the engine will run on the CPU with the default number of threads. To specify the number of threads, set this argument to cpu:${NUM_THREADS}, where ${NUM_THREADS} is the desired number of threads.
  • voiceThreshold number : Sensitivity threshold for detecting voice. The value should be a number within [0, 1]. A higher threshold increases detection confidence at the cost of potentially missing frames of voice.
  • 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.

BatScores

export type BatScores = Partial<Record<BatLanguages, number>>

Bat scores type.


BatLanguages

export enum BatLanguages { }

Bat languages enum type.


NUM_BAT_LANGUAGES

export const NUM_BAT_LANGUAGES;

Number of languages contained in the BatLanguages enum type.


batLanguageToString

export const batLanguageToString = (language: BatLanguages): string | null => {}

Returns string representation of BatLanguages enum value.

Parameters

  • language BatLanguages : BatLanguages enum value.

Returns

  • string | null : String representation or nil if language is not valid.

batLanguageFromString

export const batLanguageFromString = (language: string): BatLanguages | null => {}

Returns BatLanguages enum value given string representation.

Parameters

  • language String : String representation of enum value.

Returns

  • BatLanguages | null : BatLanguages enum value or null if string representation is not valid.

BatWorker

class BatWorker {}

A class for running the Bat Spoken Language Identification engine as a web worker thread.


BatWorker.create()

static async function create(
accessKey: string,
scoresCallback: (scores: BatScores | null) => void,
model: BatModel,
options: BatOptions = {}
): Promise<BatWorker>

Creates an instance of BatWorker.

Parameters

  • accessKey string : AccessKey obtained from Picovoice Console.
  • scoresCallback (scores: BatScores | null) => void : User-defined callback to run after receiving scores result.
  • model BatModel : Bat model options.
  • options BatOptions : Optional configuration arguments.

Returns

  • BatWorker : An instance of BatWorker.

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

Language identification scores are returned via the scoresCallback defined during init.

Parameters

  • pcm Int16Array : A frame of audio samples.

BatWorker.release()

async function release(): Promise<void>

Releases resources acquired by the Bat Web SDK.


BatWorker.terminate()

async function terminate(): Promise<void>

Force terminates the instance of BatWorker.


BatWorker.frameLength

get frameLength(): number

Number of audio samples per frame.


BatWorker.sampleRate

get sampleRate(): number

Audio sample rate accepted by Bat.


BatWorker.version

get version(): string

Bat version string.

Was this doc helpful?

Issue with this doc?

Report a GitHub Issue
Bat Spoken Language Identification Web API
  • Bat
  • create()
  • process()
  • release()
  • frameLength
  • sampleRate
  • version
  • listAvailableDevices()
  • BatModel
  • BatOptions
  • BatScores
  • BatLanguages
  • NUM_BAT_LANGUAGES
  • batLanguageToString
  • batLanguageFromString
  • BatWorker
  • create()
  • process()
  • release()
  • terminate()
  • frameLength
  • sampleRate
  • version
Voice AI
  • picoLLM On-Device LLM
  • 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
Resources
  • Docs
  • Console
  • Blog
  • Use Cases
  • Playground
Contact
  • Contact Sales
Company
  • About us
  • Careers
Follow Picovoice
  • LinkedIn
  • GitHub
  • X
  • YouTube
  • AngelList
Subscribe to our newsletter
Terms of Use
Privacy Policy
© 2019-2026 Picovoice Inc.