createSttModel abstract method

Future<SpeechRecognizer> createSttModel({
  1. String? modelPath,
  2. String? tokenizerPath,
  3. PreferredBackend? preferredBackend,
  4. String? language,
})

Creates and returns a new SpeechRecognizer instance.

Modern API: If paths are not provided, uses the active STT model set via FlutterGemma.installStt() or modelManager.setActiveModel().

modelPath — path to the STT model file (optional if active model set). tokenizerPath — path to the tokenizer file (optional if active model set). preferredBackend — backend preference (e.g., CPU, GPU). language — the OUTPUT language for transcripts, Whisper only: a bare lowercase code ('en', 'de', …). It sets SpeechRecognizer.language, the default for calls to SpeechRecognizer.transcribe that pass none, and it RETARGETS the recognizer when one already exists — this returns a process-wide singleton, so a language fixed at construction would take effect only on the first call in a process. Throws ArgumentError for a malformed code, or for any language on a model with no language token (moonshine, parakeet). null leaves the model's own default in place.

Implementation

Future<SpeechRecognizer> createSttModel({
  String? modelPath,
  String? tokenizerPath,
  PreferredBackend? preferredBackend,
  String? language,
});