Note:
- supported building platforms are Android Studio running on Mac OS X or Ubuntu. Windows is not supported.
- supported target CPU is ARMv7 (most Android phones run on ARM CPUs)
-
Install
swig
. For Mac, dobrew install swig
; for Ubuntu, dosudo apt-get install swig3.0
. Make sure yourswig
version is at least3.0.10
. -
Go to
swig/Android
and build swig wrappers for Snowboy:cd swig/Android make
Ths will generate a cross-compiled library for ARM:
jniLibs/armeabi-v7a/libsnowboy-detect-android.so
and a few Java wrapper files:
java └── ai └── kitt └── snowboy ├── SnowboyDetect.java ├── snowboy.java └── snowboyJNI.java
The generated
.so
and.java
files are hyperlinked to theexamples/Android/SnowboyAlexaDemo
folder. -
Use Android Studio to open the project in
examples/Android/SnowboyAlexaDemo
and 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 TODOs will be fixed by 2017/4 in the upcoming Snowboy v1.2.0 release.
- softfloating point support with OpenBlas
- upgrade NDK version to newer than r11c
- NDK toolchain building: remove
--stl=libc++
option