Voice Recognition Commands Android

三世轮回 提交于 2019-12-08 09:18:09

问题


So I've searched far and wide for some sort of solution to the issue regarding removing Google's Voice Recognition UI dialog when a user wants to perform a Voice Command but have been unable to find any solution. I am trying to implement an app which displays a menu to the user and the user can either click on the options or say the options out loud which will open the new pages. So far ive been unable to implement this unless I use Googles RecognizerIntent but I dont want the dialog box to pop up. Anyone have any ideas? Or has anyone solved this issue or found a workaround? Thanks

EDIT: As a compromise maybe there is a way to move the dialog to the bottom of the screen while still being able to view my menu?


回答1:


Does How can I use speech recognition without the annoying dialog in android phones help?

I'm pretty sure the Nuance/Dragon charges for production or commercial applications that use their services. If this is just a demo, you may be fine with the developer account. Android speech services are free for all Android applications.




回答2:


You know that you can do this with google's APIs.

You've probably been looking at the documentation for the speech recognition intent. Look instead at the RecognitionListener interface to the speech recognition APIs.

Here's some code to help you

public class SpeechRecognizerExample extends Activity implements RecognitionListener{    

    //This would go down in your onCreate

    SpeechRecognizer recognizer = SpeechRecognizer.createSpeechRecognizer(this);
    recognizer.setRecognitionListener(this);

    //Then you'd need to start it when the user clicks or selects a text field or something

    Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
    intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
            RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
    //intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, "zh");
    intent.putExtra("calling_package",
            "yourcallingpackage");

    recognizer.startListening(intent);

    //Then you'd need to implement the RecognitionListener functions - basically works just like a click listener

Here's the docs for a RecognitionListener:

http://developer.android.com/reference/android/speech/RecognitionListener.html



来源:https://stackoverflow.com/questions/6348829/voice-recognition-commands-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!