This week's book giveaway is in the Spring forum.
We're giving away four copies of Java Persistence with Spring Data and Hibernate and have Cătălin Tudose on-line!
See this thread for details.
Win a copy of Java Persistence with Spring Data and Hibernate this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Tim Cooke
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Jeanne Boyarsky
Saloon Keepers:
  • Stephan van Hulst
  • Carey Brown
  • Tim Holloway
  • Piet Souris
Bartenders:

Speech Recognizer does not honor lowercase tags

 
Bartender
Posts: 598
26
Oracle Notepad Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 Activity
  • Add 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.
     
    Brian Tkatch
    Bartender
    Posts: 598
    26
    Oracle Notepad Linux
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    I would even like someone (or two or three) to verify this behavior. It's easy to test. Just try a non English word, like Hola (oh-la) in Spanish or Ciao (chow) in Italian.
     
    Brian Tkatch
    Bartender
    Posts: 598
    26
    Oracle Notepad Linux
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Figured something out. Although using Locale(lang + "-" + country) does not work, regardless of case. It must have the language part alone. Locale(lang, country) seems to work, regardless of case.

    So, that means, when getting the language tag, it must be split in order to get a Locale:


    Unless i'm missing something, and there's an easier way to go from tag to Locale.
     
    Wanna see my flashlight? How about this tiny ad?
    The Low Tech Laboratory Movie Kickstarter is LIVE NOW!
    https://www.kickstarter.com/projects/paulwheaton/low-tech
    reply
      Bookmark Topic Watch Topic
    • New Topic