dex*_*tto 8 android speech-recognition
您可以在最新的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仅包含默认语言的结果.
我怎样才能得到正确的结果?
谢谢.
小智 11
虽然这在任何地方都没有记录,但我已经能够发现,在上次更新中引入了多语言支持,Google搜索现在在RecognizerIntent中采用了名为"android.speech.extra.EXTRA_ADDITIONAL_LANGUAGES"的新功能.正如其名称所示,它是一个字符串数组,除了主要语言之外,还将用于指定其他语言,它们仍将由RecognizerIntent.EXTRA_LANGUAGE提供.问题是Google Search会忽略RecognizerIntent.EXTRA_LANGUAGE,如果没有同时提供新的额外内容.这意味着在代码中添加以下行足以解决问题:
intent.putExtra("android.speech.extra.EXTRA_ADDITIONAL_LANGUAGES", new String[]{});
Run Code Online (Sandbox Code Playgroud)
但请注意,即使这有效,也不会改变Google搜索中存在错误的事实.正如我之前所说的,这个新的附加功能没有在任何地方记录,Google搜索也没有遵循Android语音识别API的规范.作为Google搜索和Android的开发者,Google应该:
更改Android中语音识别API的规范,但这会破坏向后兼容性.
更新Google搜索应用,使其正确遵循当前规范.
第二种选择显然是最合乎逻辑的选择,因此我们应该让Google了解这些错误,以便他们解决问题.看起来官方的Google搜索帮助论坛是正确的地方,但到目前为止,Google没有人关注我为此创建的主题(https://productforums.google.com/forum/#!topic/websearch/PUjEPmdSzSE/discussion).因此,如果您遇到此问题,请在那里发布您的投诉以引起Google的注意,让我们看看我们是否以这种方式获得正式答案.
| 归档时间: |
|
| 查看次数: |
2342 次 |
| 最近记录: |