public final class TextToSpeech
- Object
- TextToSpeech
Speaks text aloud using the platform’s built-in synthesizer.
- iOS –
AVSpeechSynthesizer. - Android –
android.speech.tts.TextToSpeech. - JavaSE simulator – best-effort:
sayon macOS,espeakon Linux, SAPI via PowerShell on Windows. When none of those tools are present,isSupportedreturns false andspeaksilently no-ops so simulator code paths keep working.
No permissions or Info.plist entries are required.
TextToSpeech.speak("Welcome to the demo");
Methods
public static boolean isSupported() | |
public static void speak(String text) | Speaks text using the platform default voice. |
public static void speak(String text, TtsOptions options) | |
public static void stop() | Stops any ongoing utterance. |
public static String[] getAvailableVoices() | Returns the platform-supplied voice identifiers. |
Inherited methods
Method details
isSupported
public static boolean isSupported()speak
public static void speak(String text)Speaks
text using the platform default voice. Returns
immediately; the utterance plays asynchronously.speak
public static void speak(String text, TtsOptions options)stop
public static void stop()Stops any ongoing utterance. No-op when nothing is playing.
getAvailableVoices
public static String[] getAvailableVoices()Returns the platform-supplied voice identifiers. May be empty
on platforms that don’t enumerate voices (e.g. the simulator
when relying on the system
say binary).