【问题标题】:Voice Recognition Commands Android语音识别命令 Android
【发布时间】:2011-09-14 23:37:16
【问题描述】:
因此,当用户想要执行语音命令但找不到任何解决方案时,我已经广泛搜索了有关删除 Google 语音识别 UI 对话框的问题的某种解决方案。我正在尝试实现一个向用户显示菜单的应用程序,用户可以单击选项或大声说出将打开新页面的选项。到目前为止,除非我使用 Googles RecognizerIntent,否则我无法实现这一点,但我不希望弹出对话框。谁有想法?或者有没有人解决了这个问题或找到了解决方法?谢谢
编辑:作为一种妥协,也许有一种方法可以将对话框移动到屏幕底部,同时仍然能够查看我的菜单?
【问题讨论】:
标签:
android
command
speech-recognition
voice
voice-recognition
【解决方案1】:
您知道您可以使用 google 的 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