我想知道你是如何制作像am或Siri这样的应用程序的。不那么复杂,但它允许我从用户那里获得声音输入,并通过更新的UI和声音确认来响应。例如:我花了多少钱买我的手机?该应用程序将回答“Nexus 5或三星S4?”(假设它有我所有智能手机的列表),在我回答之后,它将在UI中显示价格,并做出明确的确认。
现在,我已经看到Android M是可能的,但是大多数设备要升级到Android M还需要一段时间,我想要一个向后兼容的解决方案。
对所需的工具有什么想法吗?
谢谢,
发布于 2015-06-23 09:32:37
很长一段时间以来,已经有了一个Android。这是旧代码,但我认为它应该有效。它通过意图启动google语音识别对话框。
private void startVoiceRecognitionActivity()
{
Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
intent.putExtra(RecognizerIntent.EXTRA_PROMPT, "Voice recognition Demo...");
startActivityForResult(intent, REQUEST_CODE);
}
/**
* Handle the results from the voice recognition activity.
*/
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
if (requestCode == REQUEST_CODE && resultCode == RESULT_OK)
{
// Populate the wordsList with the String values the recognition engine thought it heard
ArrayList<String> matches = data.getStringArrayListExtra(
RecognizerIntent.EXTRA_RESULTS);
wordsList.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1,
matches));
}
super.onActivityResult(requestCode, resultCode, data);
}
有用的链接:http://android-developers.blogspot.com.es/2010/03/speech-input-api-for-android.html http://www.jameselsey.co.uk/blogs/techblog/android-how-to-implement-voice-recognition-a-nice-easy-tutorial/
https://stackoverflow.com/questions/30998340
复制相似问题