How to set the language in speech recognition on android?

前端 未结 8 1227
清歌不尽
清歌不尽 2020-11-28 06:00

I\'ve been working on speech Recognition API in android and found out that the speech results vary allot when the language settings are changed , is there a way to set it pr

相关标签:
8条回答
  • 2020-11-28 07:06

    I finally got my app to restrict voice recognition results to a specified language input (handing it, e.g., "ja" for Japanese or "fr" for French) by adding all 3 of the following extras:

    String languagePref = "de";//or, whatever iso code...
    intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, languagePref);
    intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_PREFERENCE, languagePref); 
    intent.putExtra(RecognizerIntent.EXTRA_ONLY_RETURN_LANGUAGE_PREFERENCE, languagePref);
    

    Hope this helps someone.

    0 讨论(0)
  • 2020-11-28 07:06

    this code is to set the language in speech recognization

      String languagePref = "te-IN";//this is for telugu
    
         //kannada --->  "kn-IN"
         //tamil--->  "ta-IN".....
    
                Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
                intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
                        RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
                intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, languagePref);
    
    0 讨论(0)
提交回复
热议问题