Frequently Asked Question
How to use Text to Speech
Last Updated 11 months ago
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.. */ }