Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

You can set many voice languages on the setting of latest Google search. But the problem is that SpeechRecognizer can recognize only the default language.

I implemented...

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

I request the recognition about Korean but the resultList includes only results of default language.

How can I get right result?

Thanks.

like image 918
dextto Avatar asked Aug 21 '14 02:08

dextto


2 Answers

Even though this is not documented anywhere, I've been able to find out that, with the introduction of multilanguage support in its last update, Google Search is now taking a new extra in RecognizerIntent called "android.speech.extra.EXTRA_ADDITIONAL_LANGUAGES". As suggested by its name, it is a string array that would be used to specify other languages in addition to the main one, which would still be given by RecognizerIntent.EXTRA_LANGUAGE. The problem is that Google Search ignores RecognizerIntent.EXTRA_LANGUAGE if this new extra is not given along with it. This means that adding the following line to your code is enough to solve the problem:

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

But please note that, even though this works, it doesn't change the fact that there is a bug in Google Search. As I've said before, this new extra is not documented anywhere, and Google Search is not following the specification of Android's speech recognition API. As the developer of both Google Search and Android, Google should therefore either:

  1. Change the specification of the speech recognition API in Android, but this would break backward compatibility.

  2. Update the Google Search app so that it correctly follows the current specification.

The second option is obviously the most logical one, and we should therefore let Google know about the bug so that they fix it. It looks like the official Google Search Help Forum is the right place to do this, but so far nobody from Google has paid attention to the thread I created there for it (https://productforums.google.com/forum/#!topic/websearch/PUjEPmdSzSE/discussion). So if you have had this issue please post your complains there to grab Google's attention, and let's see if we get an official answer this way.

like image 170
artetxem Avatar answered Nov 08 '22 21:11

artetxem


I found the same problem with my application.

I just try.

  1. Remove Google Search 3.6 update. It's work.
  2. Change the default language. I can use only a default language.

I'm waiting for Google update again.

Here is the Issue for this case: https://code.google.com/p/android/issues/detail?id=75347

Link on support site: https://productforums.google.com/d/topic/websearch/PUjEPmdSzSE/discussion

like image 43
Krich Charoenpoldee Avatar answered Nov 08 '22 21:11

Krich Charoenpoldee