开发者

Voice Recognition Commands Android

开发者 https://www.devze.com 2023-03-12 18:14 出处:网络
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

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 Rec开发者_C百科ognizerIntent 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?


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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消