2011-06-14 141 views
0

因此,我已经搜索了很多关于在用户想要执行语音命令但无法找到任何解决方案时删除Google语音识别UI对话框的问题的某种解决方案。我试图实现一个应用程序,向用户显示一个菜单,用户可以点击选项或大声说出选项,这将打开新的页面。到目前为止,我一直无法实现这一点,除非我使用谷歌RecognizerIntent但我不想弹出对话框。有人有主意吗?或者有谁解决了这个问题或找到解决方法?谢谢语音识别命令Android

编辑:作为一个妥协也许有一种方法可以将对话框移动到屏幕的底部,同时仍然能够查看我的菜单?

回答

1

请问How can I use speech recognition without the annoying dialog in android phones有帮助吗?

我很确定使用其服务的生产或商业应用程序的Nuance/Dragon费用。如果这只是一个演示,你可能会对开发者帐户没问题。 Android语音服务对所有Android应用程序都是免费的。

+0

我给这个一看....我从来没有看到这个线程 – 2011-06-15 12:48:17

+0

这是最终工作解决方案! – 2011-06-15 13:02:51

1

你知道你可以用谷歌的API做到这一点。

您可能一直在寻找语音识别意图的文档。在语音识别API的RecognitionListener接口上看看。

下面是一些代码,以帮助您

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 

下面是一个RecognitionListener文档:

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