TtsManager class
TtsManager - Text-to-Speech (TTS) handler
Encapsulates all logic related to voice synthesis using FlutterTts.
This class is designed to be developer-controlled, meaning:
- No user-selectable voice menu
- Predefined voice and language settings per game
Key Responsibilities:
- Initialize and configure the TTS engine
- Speak text aloud with configured pitch, speed, volume
- Handle completion and cancellation callbacks
- Expose speaking status via isSpeaking
Usage Example:
final tts = TtsManager();
await tts.initialize(language: 'en-US');
await tts.speak("Welcome to the dungeon.");
Part of the Fifty Flutter Kit.
Constructors
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- isSpeaking → bool
-
Whether the TTS engine is currently speaking
no setter
- onSpeechComplete ↔ VoidCallback?
-
Optional callback triggered when speech completes
getter/setter pair
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
changeLanguage(
String language, {String? voiceId}) → Future< void> - Changes the current TTS language and optionally sets a voice override
-
dispose(
) → void - Cleans up and stops any ongoing speech
-
initialize(
{String language = 'en-US', String? voiceId}) → Future< void> - Initializes the TTS engine with language and voice settings
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
speak(
String text) → Future< void> -
Speaks the given
textaloud -
stop(
) → Future< void> - Immediately stops any ongoing speech
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited