【问题标题】:Voice Interaction App [Android]语音交互应用 [Android]
【发布时间】:2015-06-23 17:32:37
【问题描述】:

我想知道你如何制作像 Utter 或 Siri 这样的应用程序。没有那么复杂,但可以让我从用户那里获得声音输入并以更新的 UI 和声音确认进行响应。 例如:我在手机上花了多少钱? 该应用程序将回答“Nexus 5 还是三星 S4?” (假设它有我所有智能手机的列表) 在我回答后,它会在 UI 中显示价格并带有语音确认。

现在,我发现 Android M 可以做到这一点,但大多数设备都需要一段时间才能更新到 Android M。我想要一个向后兼容的解决方案。

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

谢谢,

【问题讨论】:

    标签: android speech-recognition text-to-speech voice-recognition speech


    【解决方案1】:

    长期以来,有一个 Android API 可以执行此操作。这是旧代码,但我认为它应该可以工作。它通过一个意图启动谷歌语音识别对话框。

    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/

    【讨论】:

    • 谢谢!如果没有每次都弹出的谷歌用户界面,我可以这样做吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-06-07
    • 1970-01-01
    • 2018-10-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多