how to pass language in speech recognition on android apps?

拈花ヽ惹草 提交于 2019-12-06 09:01:58

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

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);

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

The only thing you can do for now is

intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_PREFERENCE, Locale.getDefault());  

It may not work if the recognizer engine does not support this language.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!