首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >语音交互应用[Android]

语音交互应用[Android]
EN

Stack Overflow用户
提问于 2015-06-23 09:01:31
回答 1查看 364关注 0票数 0

我想知道你是如何制作像am或Siri这样的应用程序的。不那么复杂,但它允许我从用户那里获得声音输入,并通过更新的UI和声音确认来响应。例如:我花了多少钱买我的手机?该应用程序将回答“Nexus 5或三星S4?”(假设它有我所有智能手机的列表),在我回答之后,它将在UI中显示价格,并做出明确的确认。

现在,我已经看到Android M是可能的,但是大多数设备要升级到Android M还需要一段时间,我想要一个向后兼容的解决方案。

对所需的工具有什么想法吗?

谢谢,

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-06-23 09:32:37

很长一段时间以来,已经有了一个Android。这是旧代码,但我认为它应该有效。它通过意图启动google语音识别对话框。

代码语言:javascript
运行
复制
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/

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/30998340

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档