Skip to content

ObscurusGrassator/openWakeWord-cpp

 
 

Repository files navigation

openWakeWord C++

C++ version of dscripka/openWakeWord.
Fork from @rhasspy C++ version.
This fork adds support for Android.

ATTENTION: Startup scripts automatically install non-existent tools (curl, tar, unzip, make, g++, ffmpeg, sox, arecord, pulseaudio, pactl) !
All operations are transparently logged in the terminal.

I was assisted by AI, and so far I have only tested the macOS and Android Termux versions. The Android app was also working before I added the Termux version, so I hope I didn’t break it.

Building

./build.sh

or for Androin Termux terminal:

./build-androidTermux-from-pc.sh

Not required: ---ANDROID_SDK, -onnxruntime 1.23.2
But Android Studio mut by installed.

Run with mic listening

./start.sh --model alexa_v0.1
./start.sh --model alexa_v0.1 --threshold 0.5 --trigger-level 4 --optimizeUnstableSystems
  • --model searching in openWakeWord-cpp/models, openWakeWord-cpp/../models. You can add multiple --model <path> arguments. You can generate your own wake words through the original project.
  • --optimizeUnstableSystems for lightly smartphones (DisableMemPattern, DisableCpuMemArena, ORT_DISABLE_ALL graph optimizations).
  • --help for more options.

Useful environment overrides, when auto-detection does not match your setup:

  • OPENWAKEWORD_BIN - explicit path to openwakeword executable.
  • OPENWAKEWORD_ORT_LIB_DIR - explicit ONNX Runtime lib dir for desktop.
  • ORT_LIB_DIR - explicit ONNX Runtime lib dir for Termux.
  • OPENWAKEWORD_WIN_MIC - explicit Windows microphone name for ffmpeg dshow.

If Termux microphone is not found, verify Android mic permission for Termux and PulseAudio source availability.

If Windows mic auto-detection fails, list devices with: ffmpeg -list_devices true -f dshow -i dummy

Android application

  • openWakeWord-cpp path: android/app/src/main/cpp/openWakeWord-cpp
  • onnxruntime-android path: android/app/src/main/cpp/onnxruntime-android
  • models path moved from android/app/src/main/cpp/openWakeWord-cpp/models to: android/app/src/main/assets/models

android/app/build.gradle:

android {
    defaultConfig {
        minSdkVersion 27
        ndk {
            ldLibs "log"
        }
    }
    externalNativeBuild {
        cmake {
            path "src/main/cpp/openWakeWord-cpp/src/android/CMakeLists.txt"
        }
    }

Example of Android service is in openWakeWord-cpp/src/android/OpenWakeWordServiceExample.java. There C++ part is defaulted end after waking, and started after manualy calling the service (intend) again.

  • Extras with end property end service.
  • Extras with stop property end cpp subprocess.
  • Extras with keyword property start service, or only cpp subprocess, and set wake word model path. Default is models/alexa_v0.1.onnx.
    • Optional extras sensitivity as string value. Default is 0.5.
    • Optional extras closeServiceAfterWakeWordActivation property end android service after waking (cpp subprocess is end by hardcode). Default is false.
  • Don't forget to create first NotificationChannel in MainActivity.
  • Android destroy service automaticly after same time, that's why you must set Worker, which will call this service each 16 minutes.

About

C++ version of openWakeWord

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Shell 46.4%
  • C++ 32.7%
  • Java 18.4%
  • CMake 2.1%
  • Makefile 0.4%