Android Question SpeechRecognizer works only in DEBUG mode

peacemaker

Expert
Licensed User
Longtime User
Hi, All

I tried to use in background the speech recognition (in a service)
1) this "Another SpeechRecognizer Library" https://www.b4x.com/android/forum/threads/another-speechrecognizer-library.37584/
2) and later modified this "Android Speech Recognition API Wrapper" class, to avoid using the lib: https://www.b4x.com/android/forum/threads/android-speech-recognition-api-wrapper.62959/

Both are working OK using online and offline downloaded language (Android 4.2.2 and Android 5.0 real devices), but .... only in the debug mode.
Any Release (including non-obfuscated) compilation - stops working speech recognition :-(
Compiled with targetSdkVersion="22", all sub names are with "_", no any system error in the log .....
I can publish the debug and release app APKs to try (it's simple but they are with RU interface).

How to understand this issue?
 

peacemaker

Expert
Licensed User
Longtime User
No, i mentioned. If not to suppress the start-stop beeps of SR - in release it beeps at start - at nothing happened next.
 
Last edited:
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
Erel, it have tried "DisableStrictMode" - no good news.
But why - this SR can work well without Internet at all - it works in debug with offline downloaded language pack.
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
Hmmmm, as a new project - it's work after Release compilation !!!
UPDATE:

"_onError" sub at my project was "_Error": and i did not get errors, error 5 is here - RESULT_AUDIO_ERROR, mic channel is occupied by other sub listening the silence.
Erel, thanks for idea :)
 

Attachments

  • background_speech_recognition_sample.zip
    9.7 KB · Views: 397
Last edited:
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
Erel, but the question is not answered :-(
I had misprint in event sub name _Error instead of _onError, and this event is not fired. But why in debug mode the app works as needed fully - but when compile as Release - no recognition ?!

If i fix the error in the sub name - i get standard errors from SpeechRecognizer object.
Maybe debug mode uses many DoEvents ?
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
I added DoEvents after AudioRecorder.Stop before start SpeechRecognition - and it works now in Release mode.
 
Upvote 0

tigleth

Member
Licensed User
Longtime User
Hi; i installed your example without the lib; put a startservice in activity create; startserviceat and btn_Start code in Service_Start and it works online with phone asleep in release and debug; where can i get the downloaded language pack to use it offline ? I have no idea what is going on; i like talking to my phone when it is asleep. Thank u
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
where can i get the downloaded language pack to use it offline ?
In the settings of Google speech recognition, by the settings button.

Upload you sample to check, pls.
 
Upvote 0

tigleth

Member
Licensed User
Longtime User
Hi ; here is what I did just added some stuff to your code; it works online; do I need the speech library to use this offline ? I had the language pack already and did not know. Thank u I added example code to suppress some beeps.
 

Attachments

  • !testSR.zip
    454.2 KB · Views: 402
Last edited:
Upvote 0
Top