Package org.robolectric.shadows
Class ShadowTextToSpeech
- java.lang.Object
-
- org.robolectric.shadows.ShadowTextToSpeech
-
@Implements(android.speech.tts.TextToSpeech.class) public class ShadowTextToSpeech extends Object
-
-
Constructor Summary
Constructors Constructor Description ShadowTextToSpeech()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void__constructor__(Context context, TextToSpeech.OnInitListener listener, String engine, String packageName, boolean useFallback)static voidaddLanguageAvailability(Locale locale)MakesLocalean available language returned byTextToSpeech.isLanguageAvailable(Locale).static voidaddVoice(Voice voice)MakesVoicean available voice returned byTextToSpeech.getVoices().voidclearLastSpokenText()ContextgetContext()LocalegetCurrentLanguage()ReturnsLocaleset usingTextToSpeech.setLanguage(Locale)or null if not set.VoicegetCurrentVoice()ReturnsVoiceset usingTextToSpeech.setVoice(Voice), or null if not set.StringgetLastSpokenText()StringgetLastSynthesizeToFileText()Returns last textCharSequencepassed toTextToSpeech.synthesizeToFile(CharSequence, Bundle, File, String).static TextToSpeechgetLastTextToSpeechInstance()Returns the most recently instantiatedTextToSpeechor null if none exist.TextToSpeech.OnInitListenergetOnInitListener()intgetQueueMode()com.google.common.collect.ImmutableList<String>getSpokenTextList()Returns list of all the text spoken byspeak(java.lang.String, int, java.util.HashMap<java.lang.String, java.lang.String>).UtteranceProgressListenergetUtteranceProgressListener()protected Set<Voice>getVoices()protected intinitTts()protected intisLanguageAvailable(Locale lang)booleanisShutdown()booleanisStopped()static voidreset()protected intsetLanguage(Locale locale)protected intsetVoice(Voice voice)protected voidshutdown()protected intspeak(CharSequence text, int queueMode, Bundle params, String utteranceId)protected intspeak(String text, int queueMode, HashMap<String,String> params)Speaks the string using the specified queuing strategy and speech parameters.protected intstop()protected intsynthesizeToFile(CharSequence text, Bundle params, File file, String utteranceId)Storestextand returnsTextToSpeech.SUCCESS.
-
-
-
Method Detail
-
__constructor__
@Implementation protected void __constructor__(Context context, TextToSpeech.OnInitListener listener, String engine, String packageName, boolean useFallback)
-
initTts
@Implementation protected int initTts()
-
speak
@Implementation protected int speak(String text, int queueMode, HashMap<String,String> params)
Speaks the string using the specified queuing strategy and speech parameters.- Parameters:
params- The real implementation converts the hashmap into a bundle, but the bundle argument is not used in the shadow implementation.
-
speak
@Implementation(minSdk=21) protected int speak(CharSequence text, int queueMode, Bundle params, String utteranceId)
-
shutdown
@Implementation protected void shutdown()
-
stop
@Implementation protected int stop()
-
isLanguageAvailable
@Implementation protected int isLanguageAvailable(Locale lang)
-
setLanguage
@Implementation protected int setLanguage(Locale locale)
-
synthesizeToFile
@Implementation(minSdk=21) protected int synthesizeToFile(CharSequence text, Bundle params, File file, String utteranceId)
Storestextand returnsTextToSpeech.SUCCESS.- See Also:
getLastSynthesizeToFileText()
-
setVoice
@Implementation(minSdk=21) protected int setVoice(Voice voice)
-
getVoices
@Implementation(minSdk=21) protected Set<Voice> getVoices()
-
getUtteranceProgressListener
public UtteranceProgressListener getUtteranceProgressListener()
-
getContext
public Context getContext()
-
getOnInitListener
public TextToSpeech.OnInitListener getOnInitListener()
-
getLastSpokenText
public String getLastSpokenText()
-
clearLastSpokenText
public void clearLastSpokenText()
-
isShutdown
public boolean isShutdown()
-
isStopped
public boolean isStopped()
- Returns:
trueif the TTS is stopped.
-
getQueueMode
public int getQueueMode()
-
getCurrentLanguage
public Locale getCurrentLanguage()
ReturnsLocaleset usingTextToSpeech.setLanguage(Locale)or null if not set.
-
getLastSynthesizeToFileText
public String getLastSynthesizeToFileText()
Returns last textCharSequencepassed toTextToSpeech.synthesizeToFile(CharSequence, Bundle, File, String).
-
getSpokenTextList
public com.google.common.collect.ImmutableList<String> getSpokenTextList()
Returns list of all the text spoken byspeak(java.lang.String, int, java.util.HashMap<java.lang.String, java.lang.String>).
-
addLanguageAvailability
public static void addLanguageAvailability(Locale locale)
MakesLocalean available language returned byTextToSpeech.isLanguageAvailable(Locale). The value returned byisLanguageAvailable(Locale)will vary depending on language, country, and variant.
-
addVoice
public static void addVoice(Voice voice)
MakesVoicean available voice returned byTextToSpeech.getVoices().
-
getCurrentVoice
public Voice getCurrentVoice()
ReturnsVoiceset usingTextToSpeech.setVoice(Voice), or null if not set.
-
getLastTextToSpeechInstance
public static TextToSpeech getLastTextToSpeechInstance()
Returns the most recently instantiatedTextToSpeechor null if none exist.
-
reset
@Resetter public static void reset()
-
-