posted 7 years ago
I'm messing around with language detection in multiple languages, and noticed that the language code seems to be case sensitive. The problem with this is, Locale().getLanguage() results are lowercased! Here's an example if you'd like to try and verify this behavior for me.
Create a project using the defaults and an Empty ActivityAdd the Record Audio permission to AndroidManifest.xml
Replace the XML in activity_main.xml with the following:
Replace the code in MainActivity.java with the following:
Run the app.
The objects are as follows:
If the the checkbox is checked, it will lowecase the chosen language tag.The spinner lists all dialects available for recognition, and defaults to the default language and country of the system.The text box next to it shows the language code passed to the recognition system, and in parenthesis, what Locale().getLanguage() returns for the selection.The text box between the checkbox and the button shows the first entry from what the recognizer returned.The button starts the recognition. It will also stop it, but there's no need to do so manually, as it will shortly timeout and stop on its own.On the bottom of the screen is a text box showing the most recent error.
I have found that lowercasing the tag defaults to English (either because of my system or because that is the ultimate default) and Locale().getLanguage() returns lowercase. This isn't an issue, per se, but i thought using getLanguage would be the appropriate method to use.