Code example for TextToSpeech

Methods: setOnUtteranceCompletedListenerspeak

0
            waitForInitLock.unlock();
            Log.d(D_LOG, "UNLOCK: (after waiting) WAIT INIT ");
        } 
         
        Log.d(D_LOG, "saying: " + whenTextDone.getClass().getName());
        int result = tts.setOnUtteranceCompletedListener(whenTextDone);
        if (result == TextToSpeech.ERROR)
        { 
            Log.e(D_LOG, "failed to add utterance listener");
        } 
        tts.speak(say, TextToSpeech.QUEUE_FLUSH, DUMMY_PARAMS);
    } 
     
    public void done() 
    { 
        tts.shutdown();
    } 
} 
Connect your IDE to all the code out there  Get Codota for Java