androidCheetah - Android Quick Start

Platforms

  • Android (4.4+)

Requirements

Picovoice Account & AccessKey

Signup or Login to Picovoice Console to get your AccessKey. Make sure to keep your AccessKey secret.

Quick Start

Setup

  1. Install Android Studio.

  2. Include mavenCentral() repository in the top-level build.gradle. Then add the following to the app's build.gradle:

dependencies {
// ...
implementation 'ai.picovoice:cheetah-android:${LATEST_VERSION}' // replace with latest version
}
  1. Add the following to the app's AndroidManifest.xml file to enable recording with an Android device's microphone:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />

Adding Cheetah Models

Add the Cheetah model file to your Android application by:

  1. Create a custom model using the Picovoice Console or use the default model.
  2. Add the model as a bundled resource by placing it under the ${ANDROID_APP}/src/main/assets directory of your Android application.

Usage

Use the Cheetah Builder to create an instance of Cheetah using a model from Picovoice console or using the default model.

import ai.picovoice.cheetah.*;
final String accessKey = "..."; // AccessKey provided by Picovoice Console (https://console.picovoice.ai/)
final String modelPath = "${MODEL_FILE}";
try {
Cheetah cheetah = new Cheetah.Builder()
.setAccessKey(accessKey)
.setModelPath(modelPath)
.build(appContext);
} catch (CheetahException ex) { }

Transcribe real-time audio:

short[] getNextAudioFrame() {
// .. get audioFrame
return audioFrame;
}
String transcript = "";
while true {
CheetahTranscript transcriptObj = cheetah.process(getNextAudioFrame());
transcript += transcriptObj.getTranscript();
if (transcriptObj.getIsEndpoint()) {
CheetahTranscript finalTranscriptObj = cheetah.flush();
transcript += finalTranscriptObj.getTranscript();
}
}

Free resources used by Cheetah:

cheetah.delete();

Demo

For the Cheetah Android SDK, we offer demo applications that demonstrate how to use the Speech-to-Text engine on real-time audio streams (i.e. microphone input).

Setup

Clone the Cheetah repository from GitHub using HTTPS:

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

Usage

  1. Open the Android demo using Android Studio.
  2. Copy your AccessKey from Picovoice Console into the ACCESS_KEY variable in MainActivity.java.
  3. Run the application using a connected Android device or using an Android simulator.

Resources

Packages

API

GitHub

Benchmark


Issue with this doc? Please let us know.