Android : Android TTS only speaking english

on Thursday, April 2, 2015


i have a strange issue with android tts.I have used locale.getDefault for getting default locale for tts set language.If i changed my phone locale to other languages tts not speaking anything.please help me out.



@Override
public void onInit(int status)
{
if(status == TextToSpeech.SUCCESS)
{
try
{
int result = tts.setLanguage(Locale.getDefault());

Log.e("LANGUAGE", "Result : " + result + " " + Locale.getDefault().getLanguage());

if(result == TextToSpeech.LANG_MISSING_DATA || result == TextToSpeech.LANG_NOT_SUPPORTED)
{
tts.setLanguage(Locale.ENGLISH);
}

} catch (Exception e)
{
e.printStackTrace();
}
}
}


for checking i am using a button click



btn_Check.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v)
{

String text =et_Check.getText().toString().trim();
if(!text.equals(""))
Log.e("Strnig", text);
tts.speak(text, TextToSpeech.QUEUE_FLUSH, null);

}
});


if i use Locle.English its working..But not working for other language. my logcat output is below



Result : 1 pt

0 comments:

Post a Comment