Burf2000
Burf2000

Reputation: 5193

Android TTS and Lip Sync

I am currently building a robotic head powered by Android. I am using the standard android.speech.tts.TextToSpeech however nothing jumps out to me about how I would animate or detect what it is saying so that I could do a mouth movement (I know how to control the hardware)

The only class I could see that might help is http://developer.android.com/reference/android/media/audiofx/Visualizer.html

Has anyone done Android TTS lip sync and could offer some advice?

Is there a call back method that could be hooked in to to do lip sync

Here is my code for TTS

private void speakWords(String speech) {
        //implement TTS here
        if (speech != null && speech.length() > 0) {

            HashMap<String, String> myHashAlarm = new HashMap<String, String>();
            myHashAlarm.put(TextToSpeech.Engine.KEY_PARAM_STREAM, String.valueOf(AudioManager.STREAM_ALARM));
            myHashAlarm.put(TextToSpeech.Engine.KEY_PARAM_VOLUME, "1");
            myHashAlarm.put(TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID, "SOME MESSAGE");  
            myTTS.speak(speech, TextToSpeech.QUEUE_FLUSH, myHashAlarm); //QUEUE_ADD

        }
    }

Upvotes: 3

Views: 1870

Answers (2)

vguzzi
vguzzi

Reputation: 2428

I'd recommend adding a SynthesisCallback listener to your TextToSpeechService. Doing so will allow you to receive callbacks at different intervals where you could move the robotic mouth.

See http://developer.android.com/reference/android/speech/tts/SynthesisCallback.html for more information.

Upvotes: 1

Ivan Leong
Ivan Leong

Reputation: 118

You can use a UtteranceProgressListener as explained in this post Unable to detect completion of TTS (callback) android.

This blog also explains optional parameters for playback completion callbacks http://android-developers.blogspot.co.uk/2009/09/introduction-to-text-to-speech-in.html

Upvotes: 1

Related Questions