CocoaPods trunk is moving to be read-only. Read more on the blog, there are 9 months to go.

Bat-iOS 1.0.0

Bat-iOS 1.0.0

Maintained by Eric Mikulin.



Bat-iOS 1.0.0

  • By
  • Picovoice

Bat

GitHub release GitHub

Maven Central npm CocoaPods PyPI

Made in Vancouver, Canada by Picovoice

Twitter URL YouTube Channel Views

Bat is an on-device spoken language understanding engine. Bat is:

  • Private; All voice processing runs locally.
  • Cross-Platform:
    • Linux (x86_64), macOS (x86_64, arm64), and Windows (x86_64, arm64)
    • Android and iOS
    • Chrome, Safari, Firefox, and Edge
    • Raspberry Pi (3, 4, 5)

Table of Contents

AccessKey

AccessKey is your authentication and authorization token for deploying Picovoice SDKs, including Bat. Anyone who is using Picovoice needs to have a valid AccessKey. You must keep your AccessKey secret. You would need internet connectivity to validate your AccessKey with Picovoice license servers even though the voice recognition is running 100% offline.

AccessKey also verifies that your usage is within the limits of your account. You can see your usage limits and real-time usage on your Picovoice Console Profile. To continue using Picovoice after your trial or renew and adjust your usage limits, please reach out to our Enterprise Sales Team or your existing Picovoice contact.

Language Support

  • Bat spoken language understanding currently supports English, French, Spanish, Italian, German, Portuguese, Japanese, and Korean.

Demos

Python Demos

Install the demo package:

pip3 install pvbatdemo
bat_demo_mic --access_key ${ACCESS_KEY}

C Demos

If using SSH, clone the repository with:

git clone --recurse-submodules [email protected]:Picovoice/bat.git

If using HTTPS, clone the repository with:

git clone --recurse-submodules https://github.com/Picovoice/bat.git

Build the demo:

cmake -S demo/c/ -B demo/c/build && cmake --build demo/c/build

Run the demo:

./demo/c/build/bat_demo_mic -a ${ACCESS_KEY} -m ${MODEL_PATH} -l ${LIBRARY_PATH}

Replace ${ACCESS_KEY} with yours obtained from Picovoice Console, ${LIBRARY_PATH} with the path to appropriate library under lib, and ${MODEL_PATH} to path to default model file.

iOS Demos

To run the demo, go to demo/ios/BatDemo and run:

pod install

Replace let accessKey = "${YOUR_ACCESS_KEY_HERE}" in the file ViewModel.swift with your AccessKey.

Then, using Xcode, open the generated BatDemo.xcworkspace and run the application.

Android Demos

Using Android Studio, open demo/android/BatDemo as an Android project and then run the application.

Replace "${YOUR_ACCESS_KEY_HERE}" in the file MainActivity.java with your AccessKey.

Web Demos

Vanilla JavaScript and HTML

From demo/web run the following in the terminal:

yarn
yarn start

(or)

npm install
npm run start

Open http://localhost:5000 in your browser to try the demo.

SDKs

Python

Install the Python SDK:

pip3 install pvbat

Create an instance of the engine and detect spoken language:

import pvbat

handle = pvbat.create(access_key='${ACCESS_KEY}')

def get_next_audio_frame():
    pass

while True:
    language_scores = handle.process(get_next_audio_frame())
    if language_scores:
        print(language_scores)

C

Create an instance of the engine and detect spoken language:

#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>

#include "pv_bat.h"

pv_bat_t *handle = NULL;
const pv_status_t status = pv_bat_init("${ACCESS_KEY}", "${MODEL_PATH}", "${DEVICE}", 0.4f, &handle);
if (status != PV_STATUS_SUCCESS) {
    // error handling logic
}

extern const int16_t *get_next_audio_frame(void);

while (true) {
    float *language_scores = NULL;
    const pv_status_t status = pv_bat_process(
            handle,
            get_next_audio_frame(),
            &language_scores);
    if (status != PV_STATUS_SUCCESS) {
        // error handling logic
    }

    if (language_scores != NULL) {
        // do something with language_scores
    }

    pv_bat_scores_delete(language_scores);
}

Replace ${ACCESS_KEY} with yours obtained from Picovoice Console and ${MODEL_PATH} to path to default model file. Finally, when done be sure to release resources acquired using pv_bat_delete(handle).

iOS

The Bat iOS binding is available via CocoaPods. To import it into your iOS project, add the following line to your Podfile and run pod install:

pod 'Bat-iOS'

Create an instance of the engine and detect spoken language:

import Bat

let bat = Bat(accessKey: "${ACCESS_KEY}")

func getNextAudioFrame() -> [Int16] {
  // .. get audioFrame
  return audioFrame;
}

while true {
  do {
    let languageScores = try bat.process(getNextAudioFrame())
    if languageScores != nil {
      // do something with languageScores
    }
  } catch let error as BatError {
      // handle error
  } catch { }
}

Replace ${ACCESS_KEY} with yours obtained from Picovoice Console.

Android

To include the package in your Android project, ensure you have included mavenCentral() in your top-level build.gradle file and then add the following to your app's build.gradle:

dependencies {
    implementation 'ai.picovoice:bat-android:${LATEST_VERSION}'
}

Create an instance of the engine and detect spoken language:

import ai.picovoice.bat.*;

final String accessKey = "${ACCESS_KEY}"; // AccessKey obtained from Picovoice Console (https://console.picovoice.ai/)

short[] getNextAudioFrame() {
    // .. get audioFrame
    return audioFrame;
}

try {
    Bat bat = new Bat.Builder().setAccessKey(accessKey).build(appContext);

    while true {
        HashMap<BatLanguages, Float> languageScores = bat.process(getNextAudioFrame());
        if (languageScores != null) {
            // take action based on languageScores
        }
    };

} catch (BatException ex) { }

Replace ${ACCESS_KEY} with yours obtained from Picovoice Console.

Web

Vanilla JavaScript and HTML (ES Modules)

Install the web SDK using yarn:

yarn add @picovoice/bat-web

or using npm:

npm install --save @picovoice/bat-web

Create an instance of the engine using BatWorker and process an audio file:

import { BatWorker } from "@picovoice/bat-web";
import batParams from "${PATH_TO_BASE64_BAT_PARAMS}";

function scoresCallback(scores: BatScores | null) {
  if (scores !== null) {
    // take action based on scores
  }
}

function getAudioData(): Int16Array {
  // ... function to get audio data
  return new Int16Array();
}

const bat = await BatWorker.create(
  "${ACCESS_KEY}",
  scoresCallback,
  { base64: batParams }
);

for (;;) {
  bat.process(getAudioData());
  // break on some condition
}

Replace ${ACCESS_KEY} with yours obtained from Picovoice Console. Finally, when done release the resources using bat.release().

Releases

v1.0.0 - April 1st, 2026

  • Initial release