createTtsModel method
Future<SpeechSynthesizer>
createTtsModel({
- PreferredBackend? preferredBackend,
- String? language,
override
Creates and returns a new SpeechSynthesizer for the active TTS model.
Uses the active TTS model set via FlutterGemma.installTts() /
modelManager.setActiveModel(). Native-only — throws on web.
language is TTS-only (Qwen3; ignored by Matcha) — see
RuntimeConfig.language's doc. Forwarded into the RuntimeConfig the
active model's backend builds from. A singleton for the same active
model is reused across calls, so switching languages requires
explicitly closing the previous SpeechSynthesizer first — a new
language alone does not force a rebuild.
Implementation
@override
Future<SpeechSynthesizer> createTtsModel({
PreferredBackend? preferredBackend,
String? language,
}) async {
throw UnsupportedError(
'On-device TTS is not supported on web (flutter_gemma_speech TTS is native-only).',
);
}