您可以在最新的Google搜索设置中设置多种语音语言.但问题是SpeechRecognizer只能识别默认语言.
我实施了......
private SpeechRecognizer mGoogleRecognizer;
private void startRecognition() {
mGoogleRecognizer = SpeechRecognizer.createSpeechRecognizer(m_context);
mGoogleRecognizer.setRecognitionListener(this);
Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, "ko-KR");
intent.putExtra(RecognizerIntent.EXTRA_PROMPT, "Intellectual Personal Assistant");
intent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE, m_context.getPackageName());
mGoogleRecognizer.startListening(intent);
}
@Override
public void onResults(Bundle results) {
ArrayList<String> resultList = results.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION);
}
Run Code Online (Sandbox Code Playgroud)
我要求对韩语进行识别,但resultList仅包含默认语言的结果.
我怎样才能得到正确的结果?
谢谢.
这是我的代码看起来如何.
//loc will be either "ru-RU" or "en-US"
speechRecognizerIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
speechRecognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
speechRecognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, loc);
speechRecognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_PREFERENCE, loc);
speechRecognizerIntent.putExtra(RecognizerIntent.EXTRA_ONLY_RETURN_LANGUAGE_PREFERENCE, loc);
Run Code Online (Sandbox Code Playgroud)
问题是,当我使用不同手机的程序时它运行良好.但是使用我的手机它总是选择默认语言.很少有人只是混合识别语言.就像一半的结果是用另一种语言的另一半语言.我不知道它是系统的原因还是代码本身?此外,它在我的手机上也运行良好.可以是某些设置的原因吗?我该如何克服并修复它?我需要知道如果他们遇到同样的问题,通知用户如何修复它
使用Google搜索版本3.6.14.1337016的SpeechRecognizer无法识别除默认语言之外的其他语音语言