androidPorcupine - Android API

  • Wake Word Engine
  • Offline Voice Commands
  • Local Speech Recognition
  • Always Listening
  • Android
  • Java

This document outlines how to integrate Porcupine wake word engine within an Android application.


Porcupine is implemented in ANSI C and is shipped as precompiled libraries accompanied by corresponding Java interfaces (bindings). To integrate within an Android application the following items are needed

  • Precompiled libraries
  • Java binding
  • The model file. The standard model is freely available on Porcupine's GitHub repository. Enterprises who are commercially engaged with Picovoice can access compressed and standard models as well.
  • Keyword file(s) for your use case. A set of freely-available keyword files can be found on Porcupine's GitHub repository. Enterprises who are engaged with Picovoice can create custom wake word models using Picovoice Console.


Porcupine provides a binding for Android using JNI. It can be initialized using.

final String modelPath = ...
final String keywordPath = ...
final float sensitivity = 0.5f;
Porcupine porcupine = new Porcupine(modelPath, keywordPath, sensitivity);

Sensitivity is the parameter that enables developers to trade miss rate for false alarm. It is a floating number within [0, 1]. A higher sensitivity reduces miss rate at cost of increased false alarm rate.

Once initialized, porcupine can be used to monitor incoming audio.

private short[] getNextAudioFrame();
while (true) {
final boolean result = porcupine.process(getNextAudioFrame());
if (result) {
// detection event logic/callback

Finally, be sure to explicitly release resources acquired by porcupine as the binding class does not rely on the garbage collector for releasing native resources.


Issue with this doc? Please let us know.