Reputation: 55
I am trying to make an application which uses speech to text for command input. I am making this for Android 6.0.1 and 5.1.1. I started by trying the examples with Google services, but none of them seem to work on my devices. Most of the time there is no clear error or a crash. I have gotten the no network error while using wifi and mobile internet. For the record, I did try to use the Google app speech recognition directly, but this gave no error nor answer. After that I have tried other examples which seem to not use Google services. I would also prefer for the example to work offline, but this is more of a preference than a requirement. I am looking for an example for android speech recognition which does not use any of the google services.
Some of the examples that I have tried:
Did not work on a device without Google - https://github.com/gotev/android-speech
I got a ERROR_INSUFFICIENT_PERMISSIONS error (RECORD_AUDIO and INTERNET were allowed) - http://www.truiton.com/2014/06/android-speech-recognition-without-dialog-custom-activity/
My main question is if such thing is at all possible and if yes then how (an example please)?
edit 1:
Fixed the insufficient permissions error using the example from:
https://inducesmile.com/android/android-6-marshmallow-runtime-permissions-request-example/
Now I am getting ERROR_CLIENT error (I have no idea what it means).
edit 2:
the project
logcat output
Upvotes: 1
Views: 2291
Reputation: 15775
Android devices ship with Google Mobile Services and some platform level functionality, such as an implementation of a RecognitionService
which is used by SpeechRecognizer
. The built-in service has support for offline functionality (and you can actually specify via option you prefer offline use). When not using offline support, it will need INTERNET
permission.
However, your issue is most likely with the RECORD_AUDIO
permission, particularly on Android 6+. Starting with Android 6 (Marshmallow, API 23) you have to use the runtime permissions model to gain access to any dangerous
permission (which RECORD_AUDIO
is.)
Upvotes: 2