Are there any alternatives to Android's native speech recognition engine that can be used on-device for an app? I do mean an SDK. But one that can be used on device (offline), as opposed to having to use a cloud based API.
-
Are you looking for an SDK to integrate with an app you write – or for a ready-to-use app which "shares" the recognized text to other apps?– Izzy ♦Jan 24, 2017 at 12:57
-
My apologies, I do mean an SDK. But one that can be used on device, as opposed to having to use a cloud based API– ishidoJan 24, 2017 at 13:48
-
There's Pocketsphinx. I only know that because we have a similar need for Gadgetbridge, also discussed here, where it was said not to be that useful.– Izzy ♦Jan 24, 2017 at 16:05
-
wow, love seeing so much development in this area. without starting another thread, is it possible to use one of the aforementioned methods by simply installing an android apk and changing settings to implement it in place of google voice? I will root, degoogle, and move to more privacy centric apps (an good offline gesture keyboard is also a need, as well a a private encrypted calendar service that accepts and shares ics, etc). I am not tech savvy enough to try to use vosk or deepspeech above the way described. I might be able to run a simple script once rooted. Can these be installed via an– Adam DMay 20, 2021 at 14:46
4 Answers
You can use Mozilla's DeepSpeech. Some people have reported it works on Android:
My company develops SDKs for on-device speech recognition for iOS and Android devices.
We have trial SDKs and couple of PoC apps on Github that you can use to evaluate the SDK. I recommend you review general overview pages at https://keenresearch.com/keenasr-docs and then Android-related pages.
You could use Termux-DeepSpeech and configure Android to use that instead of the "OK Google" voice assistant. It's offline and open source since it's based on Mozilla's DeepSpeech.
Do note however, that you have to define the voice commands yourself. For example:
WORDS="$(speech2text)" # This will listen to the microphone for (by default) 2 seoncds and the write what you said in the variable WORDS
if [[ "$WORDS" == "light" ]]; then # If you said the word "light"
termux-tts-speak "Turning flashlight on" # Let a robot voice say "Turning flashlight on"
termux-torch on # Turn the flashlight on
fi
-
This is awesome and should be the top answer right now! … I have to check how resource-intensive it is. Those things weren’t offline because phones were too slow, in the past. Apr 27 at 17:06
You can use Vosk, an open source speech recognition engine.
Android demo is here.
- Supports 9 languages - English, German, French, Spanish, Portuguese, Chinese, Russian, Turkish, Vietnamese. More to come.
- Works offline, even on lightweight devices - Raspberry Pi, Android, iOS Installs with simple
pip3 install vosk
- Portable per-language models are only 50Mb each, but there are much bigger server models available.
- Provides streaming API for the best user experience (unlike popular speech-recognition python packages)
- There are bindings for different programming languages, too - java/csharp/javascript etc.
- Allows quick reconfiguration of vocabulary for best accuracy.
- Supports speaker identification beside simple speech recognition.