如何创建自定义的文字转语音的语言? [英] How to create custom language for TextToSpeech?
问题描述
我需要使用印度英语或印地文(母语)语言在Android中的TTS。结果
但我没有找到有关创建自定义语言任何暗示或源$ C $ C。
I need to use Indian-English or Hindi (Mother-tongue) language for TTS in Android.
But I didn't found any hint or source code related to Creating a custom Language.
我怎么能这样做?
推荐答案
如果TSS API使用以下安装在您的模拟器设备首先检查。
First check if the TSS API is installed in your emulator device using the following.
Intent checkIntent = new Intent();
checkIntent.setAction(TextToSpeech.Engine.ACTION_CHECK_TTS_DATA);
startActivityForResult(checkIntent, MY_DATA_CHECK_CODE);
mTts.isLanguageAvailable(Locale.INDIA)); //try Locale.INDIA or Locale.INDIAN_ENGLISH or Locale.HINDI as I have not used Indian languages or Indian English dialect in it before
这将返回 TextToSpeech.LANG_COUNTRY_AVAILABLE
来指示安装这样的语言和可用的preferences。然后用一个测试以下。
which will return TextToSpeech.LANG_COUNTRY_AVAILABLE
to indicate that preferences for such a language are installed and available. Then use the following for a test.
String myText1 = "Did you sleep well?";
String myText2 = "I hope so, because it's time to wake up.";
mTts.speak(myText1, TextToSpeech.QUEUE_FLUSH, null);
mTts.speak(myText2, TextToSpeech.QUEUE_ADD, null);
更多信息,请这里
修改以检查语言可在手机上,使用 getAvailableLocales()
如下:
EDIT To check if the language is available on your phone, use getAvailableLocales()
as follows
Locale loc = new Locale("en");
Log.i("-------------",Arrays.toString(loc.getAvailableLocales()));
它应该显示在你的日志的输出结果。
It should show results in your Log output
语言codeS是由ISO 639-1定义的两个字母小写的ISO语言codeS(例如en)。该国codeS两个字母的大写的ISO国家codeS(如US)通过ISO 3166-1定义。
The language codes are two-letter lowercase ISO language codes (such as "en") as defined by ISO 639-1. The country codes are two-letter uppercase ISO country codes (such as "US") as defined by ISO 3166-1.
这篇关于如何创建自定义的文字转语音的语言?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!