可用语言的语音识别
从我读过,语音识别可用于3种语言:英语(英国,美国,金..),日本和中国(北京话)
From what I've read, speech recognition is available for 3 languages: English (UK, US, Au ..), Japanese and Chinese (Mandarin).
有谁知道如何把这些语言之间切换的详细信息? 有没有办法知道的(编程),它的语言是激活语音识别某个设备上? (也许在日本只有日本...但我可以以某种方式获得这些信息......就像一个属性或什么吗?)。
Does anyone know more details about how to switch between these languages? Is there a way to know (programatically) which language is active for speech recognition on a certain device? (maybe in Japan the only have Japanese ... but can I get this information somehow ... like a property or anything?).
任何有关这将是AP preciated帮助。
Any help regarding this will be appreciated.
谢谢你们。
要语言之间进行切换,只需使用你想要的语言并设定 Locale.toString
的语言环境 EXTRA_LANGAUGE
在你 ACTION_RECOGNIZE_SPEECH
意图。
To switch between languages, just use the Locale you want for the language and set Locale.toString
for EXTRA_LANGAUGE
in you ACTION_RECOGNIZE_SPEECH
intent.
要检查哪些语言可供选择,你需要的东西是这样的:
To check what languages are available, you need something like this:
Intent detailsIntent = new Intent(
RecognizerIntent.ACTION_GET_LANGUAGE_DETAILS);
LanguageDetailsChecker checker = new LanguageDetailsChecker();
sendOrderedBroadcast(detailsIntent, null, checker, null,
Activity.RESULT_OK, null, null);
在哪里LanguageDetailsChecker是定义为这样的一个BroadcastReceiver:
Where LanguageDetailsChecker is a BroadcastReceiver defined as something like this:
public class LanguageDetailsChecker extends BroadcastReceiver {
private static final String TAG = "LanguageDetailsChecker";
private List<String> supportedLanguages;
private String languagePreference;
public LanguageDetailsChecker() {
supportedLanguages = new ArrayList<String>();
}
@Override
public void onReceive(Context context, Intent intent) {
Bundle results = getResultExtras(true);
if (results.containsKey(RecognizerIntent.EXTRA_LANGUAGE_PREFERENCE)) {
languagePreference = results
.getString(RecognizerIntent.EXTRA_LANGUAGE_PREFERENCE);
}
if (results.containsKey(RecognizerIntent.EXTRA_SUPPORTED_LANGUAGES)) {
supportedLanguages = results
.getStringArrayList(RecognizerIntent.EXTRA_SUPPORTED_LANGUAGES);
}
}
}
这一切,code是这个项目。