Picovoice Platform
Android Quick Start
Platforms
- Android (5.0+, API 21+)
Requirements
- Picovoice Account and AccessKey
- Android Studio
- Android device with USB debugging enabled or Android simulator
Picovoice Account & AccessKey
Signup or Login to Picovoice Console to get your AccessKey
.
Make sure to keep your AccessKey
secret.
Quick Start
Setup
Install Android Studio.
Include
mavenCentral()
repository in the top-levelbuild.gradle
. Then add the following to the app'sbuild.gradle
:
- Add the following to the app's
AndroidManifest.xml
file to enable recording with an Android device's microphone:
Usage
Use the PicovoiceManager Builder
to create an instance of PicovoiceManager
using a Porcupine keyword file (.ppn
), and a Rhino context file (.rhn
):
Start audio capture and Picovoice Platform:
Stop with:
Free resources used by picovoiceManager
:
Custom Wake Words & Contexts
Create custom wake words and contexts using the Picovoice Console. Download the custom models (.ppn
and .rhn
) and add them to the ${ANDROID_APP}/src/main/assets
directory of your Android project. Pass in these file paths to the setKeywordPath
and setContextPath
builder methods. If the custom models are deployed with this method, paths should be relative to the assets
directory.
Alternatively, if the model files are deployed to the device with a different method, the absolute paths to the files on device can be used.
Non-English Languages
Use the corresponding model file (.pv
) to process non-English wake words and contexts.
The model files for all supported languages are available on the Porcupine GitHub repository and the Rhino GitHub repository. Add these files under the ${ANDROID_APP}/src/main/assets
directory of your Android project.
Pass in the model paths (relative to the assets
directory or the absolute paths to the files on device) using setPorcupineModelPath
and setRhinoModelPath
builder methods to change the language:
Demo
For the Picovoice Android SDK, we offer demo applications that demonstrate how to use the Picovoice platform on real-time audio streams (i.e. microphone input).
Setup
Clone the Picovoice repository from GitHub using HTTPS:
Usage
- Open the Android Activity demo using Android Studio.
- Copy your
AccessKey
from Picovoice Console into theACCESS_KEY
variable in MainActivity.java. - Go to
Build > Select Build Variant...
and select the language you would like to run the demo in (e.g. enDebug -> English, itRelease -> Italian) - Run the application using a connected Android device or using an Android simulator.
The demo detects the chosen keyword only when the application is in focus. To run the demo in the background, check out the other Android demos on our GitHub repository.