Skip to content
This repository has been archived by the owner on Oct 15, 2022. It is now read-only.

Android local language speech detect and text in local language #96

Open
ghure opened this issue May 24, 2020 · 1 comment
Open

Android local language speech detect and text in local language #96

ghure opened this issue May 24, 2020 · 1 comment

Comments

@ghure
Copy link

ghure commented May 24, 2020

I had issues in android for local language recognition.

Issue was speech_recognition was not detecting selected language and was giving error java.lang.IndexOutOfBoundsException

My code:
_speechRecognition
.listen(locale: "en-US")
.then((result) => print('$result'));
});

_speechRecognition
.listen(locale: "mr-IN")
.then((result) => print('$result'));
});

After spending long time on issue, i resolved issue by changing code in
SpeechRecognitionPlugin.java
-> line no 67 -> recognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, call.arguments.toString());

After changing this code works fine in android. So can any one update this line in android code
Thanks.

WhatsApp Image 2020-05-24 at 7 16 29 PM

@pinkeshmars
Copy link

In SpeechRecognitionPlugin.java, you can also change a method like this.

private Locale getLocale(String code) {
    String[] localeParts;
    if(code.contains("_")){
        localeParts = code.split("_");
    }else{
        localeParts = code.split("-");
    }
    return new Locale(localeParts[0], localeParts[1]);
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants