Android 上 TTS 的可用语言
Available languages for TTS on Android
我正在尝试使用 isLanguageAvailable()
检查某种语言是否可用于 TTS。
该方法可能的 return 值如下。
LANG_AVAILABLE
LANG_COUNTRY_AVAILABLE
LANG_COUNTRY_VAR_AVAILABLE
LANG_MISSING_DATA
LANG_NOT_SUPPORTED
很容易理解,我不必关心最后两个的名字。但即使在阅读了解释 here.
之后,我真的很困惑其他人的意思
public static final int LANG_AVAILABLE
Denotes the language is available for the language by the locale, but
not the country and variant.
public static final int LANG_COUNTRY_AVAILABLE
Denotes the language is available for the language and country
specified by the locale, but not the variant.
public static final int LANG_COUNTRY_VAR_AVAILABLE
Denotes the language is available exactly as specified by the locale.
这是什么意思?所有三者都可用于 TTS?
我不明白"by the locale, but not the country and variant"这句话。
我正在用这样的代码测试 TTS。
for( Locale each : Locale.getAvailableLocales() )
if( TextToSpeech.LANG_AVAILABLE == myTTS.isLanguageAvailable(each)
&& SOME_OTHER_ADDITIONAL_CONDITIONS ) {
myTTS.setLanguage(each);
break;
}
如你所见,我只放了一个常量LANG_AVAILABLE。
我是否也需要其他两个常量,以防万一?
好吧,正如您在此处看到的 (http://developer.android.com/reference/java/util/Locale.html) 有一个名为 en(英语)的语言环境,还有 en_GB 和 en_US,因此英语是基本语言环境GB 和 US 指定区域设置的国家/地区。如果您查看 locale 的三参数构造函数,还有一个名为 variant 的参数。我猜可能会有类似 en_US_southern 的东西,而 southern 将是美式英语的变体。
为了回答你的问题,如果你只想看看 TTS 是否讲某种语言,而不考虑国家或方言,你可以检查一下
myTTS.isLanguageAvailable(each) >= 0
因为这将检查所有三个可能的 "success" 结果。
我正在尝试使用 isLanguageAvailable()
检查某种语言是否可用于 TTS。
该方法可能的 return 值如下。
LANG_AVAILABLE
LANG_COUNTRY_AVAILABLE
LANG_COUNTRY_VAR_AVAILABLE
LANG_MISSING_DATA
LANG_NOT_SUPPORTED
很容易理解,我不必关心最后两个的名字。但即使在阅读了解释 here.
之后,我真的很困惑其他人的意思public static final int LANG_AVAILABLE
Denotes the language is available for the language by the locale, but not the country and variant.
public static final int LANG_COUNTRY_AVAILABLE
Denotes the language is available for the language and country specified by the locale, but not the variant.
public static final int LANG_COUNTRY_VAR_AVAILABLE
Denotes the language is available exactly as specified by the locale.
这是什么意思?所有三者都可用于 TTS?
我不明白"by the locale, but not the country and variant"这句话。
我正在用这样的代码测试 TTS。
for( Locale each : Locale.getAvailableLocales() )
if( TextToSpeech.LANG_AVAILABLE == myTTS.isLanguageAvailable(each)
&& SOME_OTHER_ADDITIONAL_CONDITIONS ) {
myTTS.setLanguage(each);
break;
}
如你所见,我只放了一个常量LANG_AVAILABLE。
我是否也需要其他两个常量,以防万一?
好吧,正如您在此处看到的 (http://developer.android.com/reference/java/util/Locale.html) 有一个名为 en(英语)的语言环境,还有 en_GB 和 en_US,因此英语是基本语言环境GB 和 US 指定区域设置的国家/地区。如果您查看 locale 的三参数构造函数,还有一个名为 variant 的参数。我猜可能会有类似 en_US_southern 的东西,而 southern 将是美式英语的变体。
为了回答你的问题,如果你只想看看 TTS 是否讲某种语言,而不考虑国家或方言,你可以检查一下
myTTS.isLanguageAvailable(each) >= 0
因为这将检查所有三个可能的 "success" 结果。