Question

I am using freeTTS library for converting text to speech. I am able to program my code using this library where i can play the speech for a particular text using following code:

Voice voice = VoiceManager.getInstance().getVoice("kevin16");
if (voice != null) {
    voice.allocate();
}
voice.speak("Hello world");

Is there a way using which i can get a callback when the tts lib has completed the speak process?

Was it helpful?

Solution

I found the answer myself.. we don't need a callback when the lib has completed the speak process. the control goes on the next line only when speak process ends.

that's how i did it:

    Thread t = new Thread() {
        @Override
        public void run() {
            super.run();
            try {
            voice = initializeTTS(); // a func to initialize TTS lib.
            voice.speak("Hello world");
            // do whatever you want to do from here only.
            } catch (Exception e) {
               e.printStackTrace();
            }
        }
};
t.start();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top