Note:
- supported building platforms are Android Studio running on Mac OS X or Ubuntu. Windows is not supported.
- supported target CPU is ARMv7 (32bit) and ARMv8 (64bit) (most Android phones run on ARM CPUs)
- we have prepared an Android app which can be installed and run out of box: SnowboyAlexaDemo.apk (please uninstall any previous one first if you installed this app before).
-
Install
swig. For Mac, dobrew install swig; for Ubuntu, dosudo apt-get install swig3.0. Make sure yourswigversion is at least3.0.10. You'll also needwgetto download files. -
Go to
swig/Androidand build swig wrappers for Snowboy:cd swig/Android makeTo make for ARMv8 64bit:
make BIT=64Ths will generate a cross-compiled library for ARM:
jniLibs/ ├── arm64-v8a │ └── libsnowboy-detect-android.so └── armeabi-v7a └── libsnowboy-detect-android.soand a few Java wrapper files:
java └── ai └── kitt └── snowboy ├── SnowboyDetect.java ├── snowboy.java └── snowboyJNI.javaThe generated
.soand.javafiles are hyperlinked to theexamples/Android/SnowboyAlexaDemofolder. -
Use Android Studio to open the project in
examples/Android/SnowboyAlexaDemoand run it.
Screenshot (say "Alexa" after clicking "Start"):
Don't forget to disable the "debug" option when releasing your Android App!
Note: If you need to copy the Android demo to another folder, please use the -RL option of cp to replace the relative symbol links with real files:
cp -RL SnowboyAlexaDemo Other_Folder
Note: The sample app will save/overwrite all audio to a file (recording.pcm). Make sure you do not leave it on for a long time.
To initialize Snowboy detector in Java:
# Assume you put the model related files under /sdcard/snowboy/
SnowboyDetect snowboyDetector = new SnowboyDetect("/sdcard/snowboy/common.res",
"/sdcard/snowboy/snowboy.umdl");
snowboyDetector.SetSensitivity("0.45"); // Sensitivity for each hotword
snowboyDetector.SetAudioGain(2.0); // Audio gain for detection
To run hotword detection in Java:
int result = snowboyDetector.RunDetection(buffer, buffer.length); // buffer is a short array.
You may want to play with the frequency of the calls to RunDetection(), which controls the CPU usage and the detection latency.
The following issues have been fixed pushed to master.
- softfloating point support with OpenBlas
- upgrade NDK version to newer than r11c
- NDK toolchain building: remove
--stl=libc++option
