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
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()FilegetLastSynthesizeToFile()Returns last fileFilewritten to byTextToSpeech.synthesizeToFile(CharSequence, Bundle, File, String).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()voidsimulateSynthesizeToFileResult(int result)Sets up synthesizeToFile to succeed or fail in the synthesis operation.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.
-
Constructor Details
-
ShadowTextToSpeech
public ShadowTextToSpeech()
-
-
Method Details
-
__constructor__
@Implementation protected void __constructor__(Context context, TextToSpeech.OnInitListener listener, String engine, String packageName, boolean useFallback) -
simulateSynthesizeToFileResult
public void simulateSynthesizeToFileResult(int result)Sets up synthesizeToFile to succeed or fail in the synthesis operation.This controls calls the relevant callbacks but does not set the return value of synthesizeToFile.
- Parameters:
result- TextToSpeech enum (SUCCESS, ERROR, or one of the ERROR_ codes from TextToSpeech)
-
initTts
-
speak
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
-
stop
-
isLanguageAvailable
-
setLanguage
-
synthesizeToFile
@Implementation(minSdk=21) protected int synthesizeToFile(CharSequence text, Bundle params, File file, String utteranceId) throws IOExceptionStorestextand returnsTextToSpeech.SUCCESS.- Throws:
IOException- See Also:
getLastSynthesizeToFileText()
-
setVoice
-
getVoices
-
getUtteranceProgressListener
-
getContext
-
getOnInitListener
-
getLastSpokenText
-
clearLastSpokenText
public void clearLastSpokenText() -
isShutdown
public boolean isShutdown() -
isStopped
public boolean isStopped()- Returns:
trueif the TTS is stopped.
-
getQueueMode
public int getQueueMode() -
getCurrentLanguage
ReturnsLocaleset usingTextToSpeech.setLanguage(Locale)or null if not set. -
getLastSynthesizeToFileText
Returns last textCharSequencepassed toTextToSpeech.synthesizeToFile(CharSequence, Bundle, File, String). -
getLastSynthesizeToFile
Returns last fileFilewritten to byTextToSpeech.synthesizeToFile(CharSequence, Bundle, File, String). -
getSpokenTextList
Returns list of all the text spoken byspeak(java.lang.String, int, java.util.HashMap<java.lang.String, java.lang.String>). -
addLanguageAvailability
MakesLocalean available language returned byTextToSpeech.isLanguageAvailable(Locale). The value returned byisLanguageAvailable(Locale)will vary depending on language, country, and variant. -
addVoice
MakesVoicean available voice returned byTextToSpeech.getVoices(). -
getCurrentVoice
ReturnsVoiceset usingTextToSpeech.setVoice(Voice), or null if not set. -
getLastTextToSpeechInstance
Returns the most recently instantiatedTextToSpeechor null if none exist. -
reset
-