我想显示可以通过对讲说的语言列表。当我搜索时,我找到了一种通过接收带有额外RecognizerIntent.EXTRA_SUPPORTED_LANGUAGES的广播来获取可用语音的方法。但在这里我想知道对于给定的声音说英语(美国),有多少当地人可以通过对讲应用程序阅读/说。
Ex - 当我们启用辅助功能并选择英语作为语音时,它可以读取许多设备本地(翻译),但无法读取一些。那么有没有办法找出一个声音支持多少本地人。
我想显示可以通过对讲说的语言列表。当我搜索时,我找到了一种通过接收带有额外RecognizerIntent.EXTRA_SUPPORTED_LANGUAGES的广播来获取可用语音的方法。但在这里我想知道对于给定的声音说英语(美国),有多少当地人可以通过对讲应用程序阅读/说。
Ex - 当我们启用辅助功能并选择英语作为语音时,它可以读取许多设备本地(翻译),但无法读取一些。那么有没有办法找出一个声音支持多少本地人。
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).