Available languages for speech recognition

后端 未结 2 1224
醉话见心
醉话见心 2020-12-30 18:44

From what I\'ve read, speech recognition is available for 3 languages: English (UK, US, Au ..), Japanese and Chinese (Mandarin).

Does anyone know more details about

相关标签:
2条回答
  • 2020-12-30 19:12

    To switch between languages, just use the Locale you want for the language and set Locale.toString for EXTRA_LANGAUGE in you ACTION_RECOGNIZE_SPEECH intent.

    To check what languages are available, you need something like this:

        Intent detailsIntent = new Intent(
                RecognizerIntent.ACTION_GET_LANGUAGE_DETAILS);
        LanguageDetailsChecker checker = new LanguageDetailsChecker();
        sendOrderedBroadcast(detailsIntent, null, checker, null,
                Activity.RESULT_OK, null, null);
    

    Where LanguageDetailsChecker is a BroadcastReceiver defined as something like this:

    public class LanguageDetailsChecker extends BroadcastReceiver {
    
        private static final String TAG = "LanguageDetailsChecker";
    
        private List<String> supportedLanguages;
    
        private String languagePreference;
    
        public LanguageDetailsChecker() {
            supportedLanguages = new ArrayList<String>();
        }
    
        @Override
        public void onReceive(Context context, Intent intent) {
            Bundle results = getResultExtras(true);
            if (results.containsKey(RecognizerIntent.EXTRA_LANGUAGE_PREFERENCE)) {
                languagePreference = results
                        .getString(RecognizerIntent.EXTRA_LANGUAGE_PREFERENCE);
            }
            if (results.containsKey(RecognizerIntent.EXTRA_SUPPORTED_LANGUAGES)) {
                supportedLanguages = results
                        .getStringArrayList(RecognizerIntent.EXTRA_SUPPORTED_LANGUAGES);
            }
        }
    }
    

    All this code is part of this project.

    0 讨论(0)
  • 2020-12-30 19:13

    You might want to take a look at android.speech.RecognizerIntent It looks like you can get Language support info from there by calling getVoiceDetailsIntent().

    Have a look at the API docs here

    0 讨论(0)
提交回复
热议问题