SpeechRecognizer causes ANR… I need help with Android speech API

后端 未结 6 1200
一生所求
一生所求 2020-12-01 02:14

EDIT: I should have mentioned this already, but I\'m running this code in a service. The entire app is turned on/off by a widget button and has no activity.

6条回答
  •  甜味超标
    2020-12-01 03:09

    Here is the problem I ran into, which might be related to yours. I was getting null, no matter what, from this line:

      ArrayList voiceResults = results                .getStringArrayList(RecognizerIntent.EXTRA_RESULTS);  
    

    Changing it to this completely fixed the problem:

      ArrayList voiceResults = results                .getStringArrayList("results_recognition");  
    

    I printed out the keyset from the bundle, and that was the only value. Note that the value of "results_recognition" is not the value of the string stored at RecognizerIntent.EXTRA_RESULTS. I think that's a bug, or at least it should be, since using RecognizerIntent.EXTRA_RESULTS works fine in the Activity way of doing speech recognition, but not when someone uses SpeechRecognizer.

    Anyways, i most likely won't check this website again, but please email me if you have any questions, since I now do have speech recognition working without any prompts, beeps, or anything else.

提交回复
热议问题