public final class TextToSpeech

  1. Object
  2. TextToSpeech

Speaks text aloud using the platform’s built-in synthesizer.

  • iOSAVSpeechSynthesizer.
  • Androidandroid.speech.tts.TextToSpeech.
  • JavaSE simulator – best-effort: say on macOS, espeak on Linux, SAPI via PowerShell on Windows. When none of those tools are present, isSupported returns false and speak silently 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).