Get available locales for text to speech (TTS)

前端 未结 4 1840
臣服心动
臣服心动 2020-12-04 17:02

I\'m working on a text-to-speech implementation of a flashcard program. Text in different languages should be read out. In order to do this properly the user has to select t

4条回答
  •  执念已碎
    2020-12-04 17:41

    Starting from Android 5.0 (API level 21), TextToSpeech.getAvailableLanguages has been added to fetch a set of all locales supported by the TTS engine.

    TextToSpeech tts;              // assume this is initialized
    tts.getAvailableLanguages();   // returns a set of available locales
    

    I have also noticed that the set of locales returned by TextToSpeech.getAvailableLanguages might not be a strict subset of Locale.getAvailableLocales, i.e. there might a locale supported by the TTS engine that isn't supported by the system.

提交回复
热议问题