San*_*til 2 android locale text-to-speech
我正在创建一个应用程序,用印度英语将文本转换为语音.
我从一个站点得到了这个("英语,印度(en_IN)")值,但我不知道如何以及在何处
将此值设置为语言环境.请告诉我如何设置这种语言.
并且有必要为TextToSpeech更改移动设置.
提前致谢..
确保仅在onInit()发生后设置语言.
使用以下代码:
private TextToSpeech tts;
private void createTextToSpeechForIndianEnglish()
{
tts = new TextToSpeech(context, new OnInitListener()
{
@Override
public void onInit(int status)
{
if (status == TextToSpeech.SUCCESS)
{
tts.setLanguage(new Locale("en", "IN"));
} else
{
//failed
}
}
});
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2663 次 |
| 最近记录: |