Pal*_*ini 12 android speech-to-text
我已经看过VoiceRecognition的Android示例,但我真的不明白它是做什么或者它是如何工作的.在清单中没有任何类型的主要活动要运行,因此当我在手机上安装应用程序时,我无法运行它.
我也试图找到一个简单的语音文本示例,它将语音作为输入并在屏幕上输出文本.这样我就可以研究它是如何工作的,但是我无法在网上找到任何显示它的例子.
小智 11
我这样做了:
in onCreate:
List<ResolveInfo> activities = pm.queryIntentActivities(new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH), 0);
Run Code Online (Sandbox Code Playgroud)
在启动语音识别的方法中:
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);
Run Code Online (Sandbox Code Playgroud)
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);
}
}
Run Code Online (Sandbox Code Playgroud)
希望我没有遗漏任何东西,从此过了一段时间.如果某些东西不起作用,请给我留言.关于文本输出:一旦你有一个填充的匹配数组,我相信你可以处理它.
| 归档时间: |
|
| 查看次数: |
27271 次 |
| 最近记录: |