question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Google speech recognition language not setup correctly for English

See original GitHub issue

The supported languages are defined in

ailib/src/main/java/ai/api/AIConfiguration.java

     /**
         * Currently supported languages
         */
        public enum SupportedLanguages {
            English("en"),

    ...
     public static SupportedLanguages fromLanguageTag(final String languageTag) {
                switch (languageTag) {
                   case "en":
                        return English;

The language string does not correctly setup the google recognizer, taking into account country accent i.e. en-US vs en-GB

The android specification for EXTRA_LANGUAGE http://developer.android.com/reference/android/speech/RecognizerIntent.html#EXTRA_LANGUAGE shows that it should be Optional IETF language tag (as defined by BCP 47), for example “en-US”

I suggest adding additional enums for atleast “en-US” and “en-GB”

I’ve tested replacing “en” with “en_GB” in the following code i.e. final String language = “en_GB”;

ailib/src/main/java/ai/api/services/GoogleRecognitionServiceImpl.java

    private Intent createRecognitionIntent() {
            final Intent sttIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
            sttIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
                    RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);

            final String language = config.getLanguage().replace('-', '_');

            sttIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, language);
            sttIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_PREFERENCE, language);

and I get much better speech recognition for my uk accent once this has been implemented.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
xVircommented, Apr 1, 2016

Hi, @macavalon The changes released in version 1.9.0

Thanks.

0reactions
xVircommented, Mar 25, 2016

Hi, @macavalon Great! Thanks for the info 👍 The changes will be released in nearest time.

Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Change the language or voice of spoken text - Google Help
Change the language or voice for Select-to-speak At the bottom right, select the time or press Alt + Shift + s. Select Settings....
Read more >
Android system settings for speech and voice recognition
Speech Recognition (Speech-to-Text aka STT) · Look under 'Language & Input'. · Find "Google Voice Typing", make sure it's enabled · If you...
Read more >
Speech-to-Text supported languages - Google Cloud
Name BCP‑47 Model Boost Profanity filter Afrikaans (South Africa) af‑ZA Command and search ✓ ✓ Afrikaans (South Africa) af‑ZA Default ✓ ✓ Albanian (Albania) sq‑AL Command...
Read more >
Fix Speech services by Google downloading English (US ...
Tap on the language that is not updating, English (US) in this case. ... Remember that any settings related to text-to- speech services...
Read more >
English US language code changed? Google Speech Api v2 ...
And the solution is really simple just get rid off Locale when English US is selected,ie replace en-US to en and your speech...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found