Class TextToSpeech
java.lang.Object
com.codename1.media.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,isSupported()returns false andspeak(String)silently no-ops so simulator code paths keep working.
No permissions or Info.plist entries are required.
TextToSpeech.speak("Welcome to the demo");
-
Method Summary
Modifier and TypeMethodDescriptionstatic String[]Returns the platform-supplied voice identifiers.static booleanstatic voidSpeakstextusing the platform default voice.static voidspeak(String text, TtsOptions options) static voidstop()Stops any ongoing utterance.
-
Method Details
-
isSupported
public static boolean isSupported() -
speak
Speakstextusing the platform default voice. Returns immediately; the utterance plays asynchronously. -
speak
-
stop
public static void stop()Stops any ongoing utterance. No-op when nothing is playing. -
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 systemsaybinary).
-