1 package com.android.car.messenger.tts; 2 3 import android.content.Context; 4 import android.os.Bundle; 5 import android.speech.tts.TextToSpeech; 6 import android.speech.tts.UtteranceProgressListener; 7 8 /** 9 * Interface for TTS Engine that closely matches {@link TextToSpeech}; facilitates mocking/faking. 10 */ 11 public interface TTSEngine { 12 /** 13 * Initializes engine. 14 * 15 * @param context Context to use. 16 * @param initListener Listener to monitor initialization result. 17 */ 18 void initialize(Context context, TextToSpeech.OnInitListener initListener); 19 20 /** 21 * @return Whether engine is already initialized. 22 */ 23 boolean isInitialized(); 24 25 /** 26 * @see TextToSpeech#setOnUtteranceProgressListener(UtteranceProgressListener) 27 */ 28 void setOnUtteranceProgressListener(UtteranceProgressListener progressListener); 29 30 /** 31 * @see TextToSpeech#speak(CharSequence, int, Bundle, String) 32 */ 33 int speak(CharSequence text, int queueMode, Bundle params, String utteranceId); 34 35 /** 36 * @see TextToSpeech#stop() 37 */ 38 void stop(); 39 40 /** 41 * @return Whether TTS is playing out currently. 42 */ 43 boolean isSpeaking(); 44 45 /** 46 * Un-initialize engine and release resources. 47 * {@link #initialize(Context, TextToSpeech.OnInitListener)} will need to be called again before 48 * using this engine. 49 */ 50 void shutdown(); 51 } 52