5

Here is how my code looks.

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

Problem is that, when I am using the program with different phones it works well.But with my cell phone it always chooses default language. And rare times it is just mixing recognition languages. Like half of the result is in one language other half in another language. I dont know whether it is cause of system or from code itself? Plus It worked well before on my phone too. Can it be cause of some settings? How can I overcome and fix it? I need to know to inform users how to fix it if they will have the same problem

How can I use voice recognition with other languages android

SpeechRecognizer with Google Search version 3.6.14.1337016 can't recognize other voice language except default

Community
  • 1
  • 1
vsl
  • 123
  • 1
  • 9
  • am not sure but the language your using for recognisation is must be present in your device (am not sure ) you can find these languages in your device through settings – Android is everything for me Aug 26 '14 at 10:12
  • when I change default language it is able to recognize. I also checked other languages.But the problem is that I am not able to change languages. It always picks one despite of language locale. On another devices there is not such problem – vsl Aug 26 '14 at 10:36
  • it means i was right the language your trying to use is not installed or configured in that device you can download it first in that device google it how to do that you will get its answer – Android is everything for me Aug 26 '14 at 10:43
  • 1
    well on settings there is primary language. it is russian others were checked too. the problem is that I can check one primary language only. Maybe somehow I should force locale inside intent. Dont know but it works with different devices. But in mine it always fallback to default – vsl Aug 26 '14 at 10:47
  • coming to downloading. indeed my device supports offline recognition. and I have both languages. But still program cant chose recognition language. plus sometimes it recognize half in one lnaugae half in another. I checked google translate app. but their application worked. but it seems they use different api than androids – vsl Aug 26 '14 at 10:53
  • I suspect some setting is forcing my application to use device settings – vsl Aug 26 '14 at 10:56
  • may be google recogntion is online not sure try to use it in offline mode – Android is everything for me Aug 26 '14 at 11:19
  • Also asked at http://stackoverflow.com/questions/25417439/speechrecognizer-with-google-search-version-3-6-14-1337016-cant-recognize-other – Nikolay Shmyrev Aug 26 '14 at 15:15
  • And at http://stackoverflow.com/questions/25467163/how-can-i-use-voice-recognition-with-other-languages-android?lq=1 – Nikolay Shmyrev Aug 26 '14 at 15:16
  • mm google search problem. hope they will fix it or show how to overcome this issue – vsl Aug 27 '14 at 05:25

2 Answers2

5

Firstly, the problem exists while using SpeechRecognizer
On this case only solution was to delete google search cause it is related to google search update. Doing so we will delete all updates. This worked on my own device

But on my opinion,actually, small updates should not change api behaviour. I hope there is programmatic way to solve this issue or there will be new update that will fix it

Here is undocumented programmatic solve:

intent.putExtra("android.speech.extra.EXTRA_ADDITIONAL_LANGUAGES", new String[]{});

it is artetxem's answer

Other solution is just to call activity for recognition. This way google's dialog activity will be seen but there will be no language problems.

Issue opened by me issue

Issue opened on google search by artetxem issue

Community
  • 1
  • 1
vsl
  • 123
  • 1
  • 9
0

Hi @VSL i was also facing same problem to set language hindi instead of english, but Speech recognizer always take my Android OS default language which is english. But below code solved my problem

     Intent recognizerIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
     recognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, "hi");
     recognizerIntent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE, InteractionActivity.this.getPackageName());  
     recognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_WEB_SEARCH);
     recognizerIntent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, 3);
     speech.startListening(recognizerIntent);
Sachin Tanpure
  • 1,068
  • 11
  • 12