Package org.robolectric.shadows
Class ShadowTextToSpeech
java.lang.Object
org.robolectric.shadows.ShadowTextToSpeech
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
__constructor__
(Context context, TextToSpeech.OnInitListener listener, String engine, String packageName, boolean useFallback) static void
addLanguageAvailability
(Locale locale) MakesLocale
an available language returned byTextToSpeech.isLanguageAvailable(Locale)
.static void
MakesVoice
an available voice returned byTextToSpeech.getVoices()
.void
ReturnsLocale
set usingTextToSpeech.setLanguage(Locale)
or null if not set.ReturnsVoice
set usingTextToSpeech.setVoice(Voice)
, or null if not set.Returns last fileFile
written to byTextToSpeech.synthesizeToFile(CharSequence, Bundle, File, String)
.Returns last textCharSequence
passed toTextToSpeech.synthesizeToFile(CharSequence, Bundle, File, String)
.static TextToSpeech
Returns the most recently instantiatedTextToSpeech
or null if none exist.int
com.google.common.collect.ImmutableList<String>
Returns list of all the text spoken byspeak(java.lang.String, int, java.util.HashMap<java.lang.String, java.lang.String>)
.protected Voice
getVoice()
Returns the Voice instance describing the voice currently being used for synthesis requests.protected int
initTts()
protected int
isLanguageAvailable
(Locale lang) boolean
boolean
static void
reset()
protected int
setLanguage
(Locale locale) Sets the text-to-speech language.protected int
protected void
shutdown()
void
simulateSynthesizeToFileResult
(int result) Sets up synthesizeToFile to succeed or fail in the synthesis operation.protected int
speak
(CharSequence text, int queueMode, Bundle params, String utteranceId) protected int
Speaks the string using the specified queuing strategy and speech parameters.protected int
stop()
protected int
synthesizeToFile
(CharSequence text, Bundle params, File file, String utteranceId) Storestext
and 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 protected int speak(CharSequence text, int queueMode, Bundle params, String utteranceId) -
shutdown
-
stop
-
isLanguageAvailable
-
setLanguage
Sets the text-to-speech language.This method sets the current voice to the default one for the given Locale; getVoice() can be used to retrieve it.
-
synthesizeToFile
@Implementation protected int synthesizeToFile(CharSequence text, Bundle params, File file, String utteranceId) throws IOException Storestext
and returnsTextToSpeech.SUCCESS
.- Throws:
IOException
- See Also:
-
setVoice
-
getVoice
Returns the Voice instance describing the voice currently being used for synthesis requests. -
getVoices
-
getUtteranceProgressListener
-
getContext
-
getOnInitListener
-
getLastSpokenText
-
clearLastSpokenText
public void clearLastSpokenText() -
isShutdown
public boolean isShutdown() -
isStopped
public boolean isStopped()- Returns:
true
if the TTS is stopped.
-
getQueueMode
public int getQueueMode() -
getCurrentLanguage
ReturnsLocale
set usingTextToSpeech.setLanguage(Locale)
or null if not set. -
getLastSynthesizeToFileText
Returns last textCharSequence
passed toTextToSpeech.synthesizeToFile(CharSequence, Bundle, File, String)
. -
getLastSynthesizeToFile
Returns last fileFile
written 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
MakesLocale
an available language returned byTextToSpeech.isLanguageAvailable(Locale)
. The value returned byisLanguageAvailable(Locale)
will vary depending on language, country, and variant. -
addVoice
MakesVoice
an available voice returned byTextToSpeech.getVoices()
. -
getCurrentVoice
ReturnsVoice
set usingTextToSpeech.setVoice(Voice)
, or null if not set. -
getLastTextToSpeechInstance
Returns the most recently instantiatedTextToSpeech
or null if none exist. -
reset
-