本文介绍了如何在Android应用程序的语音识别中传递语言?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在研究Android中的语音识别API,发现当语言设置发生变化时语音结果会有所不同,有没有办法以编程方式设置它?或者是否打算在语音设置屏幕上午餐?或者还有什么?注意:我试图使用额外的这个意图:

I've been working on speech Recognition API in android and found out that the speech results vary allot when the language settings are changed , is there a way to set it programmatically ? or is there an intent to lunch the speech language settings screen ? or what else ? note: I tried to use this intent extra:

intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_PREFERENCE, "en-US");

Intent detailsIntent =  new Intent(RecognizerIntent.ACTION_GET_LANGUAGE_DETAILS);
sendOrderedBroadcast(detailsIntent, null, new LanguageDetailsChecker(), null, Activity.RESULT_OK, null, null);


推荐答案

是的hanifs,这种方法对我不起作用还有。

Yes hanifs, that method didn't work for me also.

我的默认设备语言是英语美国,但我需要SR的意大利语。
只应用所有这三个额外内容,我成功使用Google Engine(用作我设备的默认语音引擎)来使用意大利语。

My default device language is English US, but I needed Italian for SR.Only applying all these three extras I succeded forcing Google Engine (used as default speech engine from my device) to use Italian.

String myLanguage = "it"; //or, Locale.Italian.toString()
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, myLanguage);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_PREFERENCE, myLanguage);
intent.putExtra(RecognizerIntent.EXTRA_ONLY_RETURN_LANGUAGE_PREFERENCE, myLanguage);

尝试这种方式自定义myLanguage变量,应该没问题!

Try this way customizing your "myLanguage" variable, it should be ok!

这篇关于如何在Android应用程序的语音识别中传递语言?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-13 08:04