0

I want to display list of languages which can be spoken by talkback. When I searched I found a way to get available voices by receiving broadcast with extra RecognizerIntent.EXTRA_SUPPORTED_LANGUAGES. but here I want to know for a given voice say English (USA), how many locals can be read/spoken by talkback application.

Ex - When we enable accessibility, and choose English as voice, it can read many device locals (translations), but it can't read some. So Is there a way to find out how many Locals are supported for one voice.

Cœur
  • 37,241
  • 25
  • 195
  • 267
sits_1608
  • 29
  • 3

1 Answers1

0

TalkBack uses the installed text-to-speech (TTS) engines to produce its spoken output, e.g. Pico, rather than speak for itself.

An introduction to Text-To-Speech in Android will get you started with the TTS engines, and then you need to ask the engine which languages it supports using TextToSpeech.isLanguageSupported(Locale) - see Android docs.

The phone also has to support the Locale, so use Locale.getAvailableLocales() to determine that. A locale is a language, which may optionally have an associated country and variant.

To obtain the full list of supported locales, use:

TextToSpeech tts = new TextToSpeech(context, listener);
for (Locale locale : Locale.getAvailableLocales()) {
    if (tts.isLanguageSupported(locale)) {
       // spoken language supported
    }
}

Finally, for your example, you'll need to filter this list by language, i.e. Locale.getLanguage(), to determine which are English (in your case).

AwayTeam
  • 439
  • 5
  • 13