Knowledge Base - How to use Text to Speech (Android)

Knowledge Base - How to use Text to Speech (Android)

This article shows how to use Text to Speech APIs.

private static TextToSpeech tts = null;
private void startTTS(Context context, final String text){
tts = new TextToSpeech(context, new TextToSpeech.OnInitListener() {
@Override
public void onInit(int status) {
tts.setLanguage(Locale.getDefault());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
tts.speak(text, TextToSpeech.QUEUE_FLUSH, null, "Done");
else
tts.speak(text, TextToSpeech.QUEUE_FLUSH, null);
}
});
}

If you call this method in the OnPDFSelectEnd(String text) of PDFViewAct, you will reproduce the selected text with TTS.


@Override
public void OnPDFSelectEnd(String text) {
startTTS(this, text);

/* ..some code.. */
}

 

Applies To

RadaeePDF SDK for Android, Other

Details

Created : 2017-11-08 10:50:32, Last Modified : 2017-11-08 11:03:46