I try to use a TextToSpeech in my app,
String text = editText.getText().toString();
tts.speak(text, TextToSpeech.QUEUE_FLUSH, null);
But the fu
String text = editText.getText().toString();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
tts.speak(text,TextToSpeech.QUEUE_FLUSH,null,null);
} else {
tts.speak(text, TextToSpeech.QUEUE_FLUSH, null);
}
Here is the complete work that work for me
Private TextToSpeech ts
ts=new TextToSpeech(CurrentActivity.this, new TextToSpeech.OnInitListener() {
@Override
public void onInit(int status) {
String text = "Any Text to Speak";
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
ts.speak(text,TextToSpeech.QUEUE_FLUSH,null,null);
} else {
ts.speak(text, TextToSpeech.QUEUE_FLUSH, null);
}
}
});