Android的语音到文本示例 [英] Android Speech to Text Example

查看:141
本文介绍了Android的语音到文本示例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看过了Android例子VoiceRecognition,但我真的不明白什么是该做的还是它的工作原理。在清单中没有任何一种主要活动的运行,所以当我在我的手机上安装应用程序无法运行它。

I've looked at the Android example for VoiceRecognition, but I don't really understand what it is suppose to do or how it works. In the manifest there isn't any sort of main activity to run and so when I install the app on my phone I can't run it.

我也试图找到讲话的文本是需要语音作为输入和输出在屏幕上的文字一个简单的例子。只是这样我就可以研究它,看看它是如何工作的,但我一直没能找到任何种类的例子,显示它在网络上。

I'm also trying to find a simple example of Speech to text that takes speech as input and outputs the text on the screen. Just so I can study it to see how it works, but I haven't been able to find any sort of example on the web that shows it.

推荐答案

我做到了这样的:

在的onCreate:

in onCreate:

List<ResolveInfo> activities = pm.queryIntentActivities(new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH), 0);

在启动语音识别方法:

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);

onActivityResult:

onActivityResult:

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);
    }
}

希望我不会遗漏任何东西,因为是一个时间。请给我一张纸条,如果事情不工作。关于文本输出:我敢肯定,你可以处理,一旦你有一个人口匹配阵列

Hope I'm not missing anything, been a time since. Drop me a note if something doesn't work. About the text output: I'm sure you can handle that once you have a populated matches array.

这篇关于Android的语音到文本示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆