[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6BXT73D6R1CM58XZZSAEP1A":3,"skill-same:01M6BXT73D6R1CM58XZZSAEP1A":72},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":23,"publishedAt":44,"linkOnly":45,"markdownContent":46,"markdownBody":47,"frontMatter":48,"refName":49,"commitSha":50,"skillDirectory":51,"forksCount":52,"repositoryHtmlUrl":53,"repositoryHomepageUrl":54,"ownerHtmlUrl":55,"ownerBlogUrl":6,"ownerDescription":56,"updatedAt":57,"install":58,"resources":71},"01M6BXT73D6R1CM58XZZSAEP1A","flutter-edge-ai-speech",null,"Use when adding speech to a flutter_edge_ai app — speech-to-text (transcribe a voice note, dictation, Whisper, moonshine, Parakeet), text-to-speech (Matcha, Qwen3-TTS, Inflect), or a push-to-talk voice assistant with VoiceSession. Also use when transcripts come back in English for non-English audio, a WAV file has to become 16 kHz PCM, synthesized audio plays at the wrong pitch, or getActiveTts throws a StateError about the language. For audio sent straight to Gemma in a chat, use flutter-edge-ai-inference.","DenisovAV\u002Fflutter_edge_ai","DenisovAV","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F9622910?v=4","01M6BXRH02KTWK364FYEH4AECE","Sasha Denisov","01M6BXRH45KJKJ712H82EV47AS",662,"MIT","https:\u002F\u002Fgithub.com\u002FDenisovAV\u002Fflutter_edge_ai\u002Fblob\u002Fmain\u002Fpackages\u002Fflutter_edge_ai\u002Fskills\u002Fflutter-edge-ai-speech\u002FSKILL.md",[18],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000016","图像与多媒体","SCENARIO","使用场景",[24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43],"edge","edge ai","flutter edge ai speech","flutter","speech","for","parakeet","at","whisper","english","when","pitch","inflect","app","back","assistant","text","transcribe","Audio","push","2026-11-10 10:12:30",false,"---\nname: flutter-edge-ai-speech\ndescription: Use when adding speech to a flutter_edge_ai app — speech-to-text (transcribe a voice note, dictation, Whisper, moonshine, Parakeet), text-to-speech (Matcha, Qwen3-TTS, Inflect), or a push-to-talk voice assistant with VoiceSession. Also use when transcripts come back in English for non-English audio, a WAV file has to become 16 kHz PCM, synthesized audio plays at the wrong pitch, or getActiveTts throws a StateError about the language. For audio sent straight to Gemma in a chat, use flutter-edge-ai-inference.\n---\n\n# Speech with flutter_edge_ai_speech\n\n## Rules\n\n1. Depend on `flutter_edge_ai` and `flutter_edge_ai_speech`, and import both. The speech package does not re-export core.\n2. `transcribe` takes raw PCM — 16 kHz, mono, 16-bit little-endian, as a `Uint8List` — and returns the text. Not a WAV file, not 44.1 or 48 kHz: nothing resamples or converts it.\n3. Play synthesized audio at `synth.sampleRate`. It differs per model.\n4. Only Whisper has a selectable output language. moonshine-tiny and Parakeet are English-only, and passing a language to them throws `ArgumentError`.\n5. STT language: set a default with `getActiveStt(language:)` or override one call with `transcribe(pcm, language:)`. Nothing reloads.\n6. TTS language: `close()` the synthesizer first. Asking a live synthesizer for another language throws `StateError`.\n7. Android needs `minSdk 30`. There is no web support — the web backends throw `UnsupportedError`.\n8. Close recognizers and synthesizers.\n\n## Setup\n\n```sh\nflutter pub add flutter_edge_ai flutter_edge_ai_speech\n```\n\n```dart\nimport 'package:flutter_edge_ai\u002Fflutter_edge_ai.dart';\nimport 'package:flutter_edge_ai_speech\u002Fflutter_edge_ai_speech.dart';\n\nawait FlutterEdgeAi.initialize(\n  sttBackends: [LiteRtSttBackend()],\n  ttsBackends: [LiteRtTtsBackend()],\n);\n```\n\nSpeech runs on the same native libraries as the `.litertlm` engine. Its build setup — Android `minSdk 30`, the Apple entries — is in the flutter-edge-ai-inference skill's [platform setup](..\u002Fflutter-edge-ai-inference\u002Freferences\u002Fplatform-setup.md), installed alongside this one.\n\n## Speech-to-text\n\nAn STT model is two files — the model and its tokenizer — usually from different repos. A catalog build (`LiteRtSpeechModels`, installed with `installStt().fromCatalog`) carries both, pinned to their Hugging Face commits; `install()` skips files already on disk. `FlutterEdgeAi.installStt()` installs your own files.\n\n```dart\nawait FlutterEdgeAi.installStt().fromCatalog(LiteRtSpeechModels.whisperTiny.f32)\n    .install();\n\nfinal SpeechRecognizer recognizer = await FlutterEdgeAi.getActiveStt(language: 'de');\ntry {\n  final String german = await recognizer.transcribe(germanPcm);\n  final String french = await recognizer.transcribe(frenchPcm, language: 'fr');\n} finally {\n  await recognizer.close();\n}\n```\n\n| `SttModelType` | Languages | Window |\n| --- | --- | --- |\n| `SttModelType.moonshine` | English | 5 s |\n| `SttModelType.whisper` | 99, selectable, default `'en'` | 30 s |\n| `SttModelType.parakeet` | English | 5 s; f32 is 2.35 GB, for desktop — on a Galaxy S23 (8 GB) its GPU load was killed. On a phone use the int8 `parakeet_ctc_0.6b_5s_i8.tflite` (596 MB) on the CPU (#747) |\n\nOn the GPU, run the f32 files: on Adreno 740 the int8 (`_i8`) ones did not compile there, and the load fails with an error naming the file.\n\n**Audio longer than the window is silently truncated**, not rejected: it is zero-padded when shorter and cut when longer, so a 40-second clip on Whisper returns the first 30 seconds with no error. Split long recordings yourself.\n\nWhisper tiny is weak outside English. Whisper base int8 is the next size up in the catalog: `LiteRtSpeechModels.whisperBase.i8`. Every speech build and where it has been run: https:\u002F\u002Fflutteredge.ai\u002Fdocs\u002Fregistry.\n\n## Getting 16 kHz mono PCM\n\nThe package has no resampler and no WAV reader. Record in the right format from the start — with the `record` package:\n\n```dart\nimport 'package:record\u002Frecord.dart';\n\nconst config = RecordConfig(\n  encoder: AudioEncoder.wav,\n  sampleRate: 16000,\n  numChannels: 1,\n);\n```\n\nRecording needs microphone access. On Android `record` declares `android.permission.RECORD_AUDIO` in its own manifest and the manifest merger adds it to the app; iOS and macOS need entries of your own:\n\n```xml\n\u003C!-- ios\u002FRunner\u002FInfo.plist and macos\u002FRunner\u002FInfo.plist -->\n\u003Ckey>NSMicrophoneUsageDescription\u003C\u002Fkey>\n\u003Cstring>Speech is transcribed on this device.\u003C\u002Fstring>\n\n\u003C!-- macos\u002FRunner\u002FDebugProfile.entitlements and macos\u002FRunner\u002FRelease.entitlements -->\n\u003Ckey>com.apple.security.device.audio-input\u003C\u002Fkey>\n\u003Ctrue\u002F>\n```\n\nThe macOS sandbox withholds the microphone without the entitlement, and it has to be in both entitlements files. On Android, iOS and macOS the user must also allow it at run time; `hasPermission()` asks, so call it before recording:\n\n```dart\nfinal recorder = AudioRecorder();\nif (!await recorder.hasPermission()) return;\n```\n\nThat produces a WAV file. Its header is not always 44 bytes — take the samples from the `data` chunk:\n\n```dart\nimport 'dart:typed_data';\n\n\u002F\u002F\u002F The samples of a 16 kHz mono 16-bit WAV file, without its header.\nUint8List pcmFromWav(Uint8List wav) {\n  final view = ByteData.sublistView(wav);\n  var offset = 12; \u002F\u002F after 'RIFF', the size and 'WAVE'\n  while (offset + 8 \u003C= wav.length) {\n    final id = String.fromCharCodes(wav, offset, offset + 4);\n    final size = view.getUint32(offset + 4, Endian.little);\n    final start = offset + 8;\n    if (id == 'data') {\n      final end = start + size > wav.length ? wav.length : start + size;\n      return Uint8List.sublistView(wav, start, end);\n    }\n    offset = start + size + (size & 1); \u002F\u002F chunks are padded to an even size\n  }\n  throw const FormatException('WAV file has no data chunk');\n}\n```\n\nA file recorded at another rate or channel count — 44.1 kHz stereo, say — has to be converted first: average the channels to mono, then resample with a low-pass filter. Dropping samples instead aliases and costs accuracy.\n\n## Traps\n\n**Transcript comes back in English**\n- Symptom: German audio, fluent English text, no error.\n- Cause: Whisper's language token decides the output language, not what it understands — with `'en'` it translates. moonshine only ever produces English.\n- Fix: use Whisper and pass `language:`.\n\n**A language is rejected**\n- Whisper codes are bare and lowercase: `'de'`, not `'de-DE'`, `'DE'` or `'german'`. Malformed codes throw `ArgumentError` from `getActiveStt`.\n- A well-formed code the installed checkpoint lacks (e.g. `'zz'`) throws `ArgumentError` from `transcribe`.\n\n## Text-to-speech\n\n```dart\nawait FlutterEdgeAi.installTts().fromCatalog(LiteRtSpeechModels.matchaTts.bundle)\n    .install();\n\nfinal SpeechSynthesizer synth = await FlutterEdgeAi.getActiveTts();\ntry {\n  final audio = await synth.synthesize('Hello world.'); \u002F\u002F 16-bit PCM\n  final rate = synth.sampleRate;                        \u002F\u002F 22050 for Matcha\n} finally {\n  await synth.close();\n}\n```\n\n| `TtsModelType` | Languages |\n| --- | --- |\n| `TtsModelType.matcha` | English, fixed by the installed bundle — it ignores `language:` |\n| `TtsModelType.qwen3` | `chinese`, `english`, `german`, `italian`, `portuguese`, `spanish`, `japanese`, `korean`, `french`, `russian`, or `auto` |\n| `TtsModelType.inflect` | English |\n\n`TtsModelType.supertonic` and `TtsModelType.kokoro` are in the enum but throw `UnimplementedError` — do not use them.\n\nTo ship the voice with the app instead of downloading it, swap `fromNetwork` for one of:\n\n| Call | Expects | Notes |\n| --- | --- | --- |\n| `fromAsset('assets\u002Ftts\u002Fmatcha\u002F')` | Flutter asset directory laid out like the HF repo | Declare every subdirectory in `pubspec.yaml` (Qwen3 has `tables\u002F` and `voices\u002F`); copied into app storage |\n| `fromFile('\u002Fabs\u002Fdir')` | Directory on disk, same layout | Used in place and stays the app's — `uninstallTts()` leaves these files |\n| `fromBundled()` | Native resources named `\u003Ctype>__\u003Cfile>`, e.g. `matcha__config.json` | Android `assets\u002Fmodels\u002F`, iOS Runner target; Android and iOS only |\n\nInflect's four Matcha G2P files go next to its own two. A missing file fails `install()` with the full list before the current voice is replaced; a switch that fails partway (lost connection) leaves no voice active, so `getActiveTts` throws until `install()` is run again. `install()` throws `UnsupportedError` on web. To ship a changed voice in an app update, use a new asset directory (a bundled voice refreshes itself); with `fromFile` on iOS, call `install()` at launch, because the data directory moves on update.\n\nSwitching the Qwen3 language — full lowercase names, not ISO codes, and only with the Qwen3 bundle installed (Matcha still throws the same `StateError` but the language changes nothing):\n\n```dart\nfinal english = await FlutterEdgeAi.getActiveTts(language: 'english');\nawait english.close();\nfinal german = await FlutterEdgeAi.getActiveTts(language: 'german');\n```\n\nWithout the `close()`, the second call throws `StateError: Active TTS synthesizer was created for language 'english'; call close() before requesting 'german'.`\n\n## Voice assistant\n\n`VoiceSession` runs one push-to-talk turn: transcribe, generate, speak, with barge-in. It uses the recognizer's current language.\n\nWrap the loop in `try`\u002F`catch`: a failed stage — transcribe, generate or synthesize — arrives as a **stream error**, not as an event. `VoiceErrorEvent` is reserved in this release and never emitted; the `case` is only there because the switch must be exhaustive. To barge in, call `await voice.interrupt()` — cancelling the subscription is not a portable stop.\n\n```dart\nfinal reply = StringBuffer();\nfinal voice = VoiceSession.fromChat(\n  recognizer: await FlutterEdgeAi.getActiveStt(language: 'de'),\n  chat: chat,\n  synthesizer: await FlutterEdgeAi.getActiveTts(),\n);\n\nawait for (final event in voice.runTurn(pcm16kMono)) {\n  switch (event) {\n    case VoiceTranscriptEvent(:final text):\n      print('heard: $text');\n    case VoiceReplyTextEvent(:final chunk):\n      reply.write(chunk);\n    case VoiceReplyAudioEvent(:final sampleRate):\n      print('audio at $sampleRate Hz');\n    case VoiceTurnInterruptedEvent():\n      print('interrupted — stop the player');\n    case VoiceTurnCompleteEvent():\n      print('done');\n    case VoiceErrorEvent(:final error):\n      print('failed: $error');\n  }\n}\n```\n\n`chat` is an `InferenceChat` from the flutter-edge-ai-inference skill. A chat created with tools also needs `onToolCall:` — without it `fromChat` throws.\n\n### Audio turns: no speech-to-text\n\nA model that hears audio (Gemma 4 or Gemma 3n E2B\u002FE4B as `.litertlm`, native platforms only) can take the recording itself: `runAudioTurn` skips the transcription and sends the PCM to the chat. Set `supportAudio: true` on `getActiveModel`, which loads the audio encoder; `openChat` takes the flag from the model unless you pass it, and on a chat whose `supportAudio` is false `runAudioTurn` throws `StateError`. It takes the same 16 kHz mono 16-bit PCM as `runTurn`, and wraps it in a WAV header, because a `.litertlm` model decodes an audio file; a custom `VoiceResponder.respondToAudio` gets that WAV and can pass it to `AgentSession.ask(audioBytes:)` as is. There is no `VoiceTranscriptEvent`, the complete and interrupted events carry an empty transcript, and a recording under 2 bytes completes without asking the model. After a barge-in, a stopped partial exchange remains in chat history; current LiteRT-LM recovery either rewinds it or rebuilds from full message history, including earlier audio, so the next turn does not forget that media. Requires `flutter_edge_ai_speech` 0.5.7 or later.\n\n```dart\nfinal model = await FlutterEdgeAi.getActiveModel(\n  maxTokens: 4096,\n  supportAudio: true,\n);\nfinal chat = await model.openChat(supportAudio: true, maxOutputTokens: 128);\nfinal voice = VoiceSession.fromChat(\n  recognizer: recognizer,\n  chat: chat,\n  synthesizer: synth,\n);\n\ntry {\n  await for (final event in voice.runAudioTurn(pcm16kMono)) {\n    if (event is VoiceReplyTextEvent) print(event.chunk);\n  }\n} finally {\n  await chat.close();\n}\n```\n","# Speech with flutter_edge_ai_speech\n\n## Rules\n\n1. Depend on `flutter_edge_ai` and `flutter_edge_ai_speech`, and import both. The speech package does not re-export core.\n2. `transcribe` takes raw PCM — 16 kHz, mono, 16-bit little-endian, as a `Uint8List` — and returns the text. Not a WAV file, not 44.1 or 48 kHz: nothing resamples or converts it.\n3. Play synthesized audio at `synth.sampleRate`. It differs per model.\n4. Only Whisper has a selectable output language. moonshine-tiny and Parakeet are English-only, and passing a language to them throws `ArgumentError`.\n5. STT language: set a default with `getActiveStt(language:)` or override one call with `transcribe(pcm, language:)`. Nothing reloads.\n6. TTS language: `close()` the synthesizer first. Asking a live synthesizer for another language throws `StateError`.\n7. Android needs `minSdk 30`. There is no web support — the web backends throw `UnsupportedError`.\n8. Close recognizers and synthesizers.\n\n## Setup\n\n```sh\nflutter pub add flutter_edge_ai flutter_edge_ai_speech\n```\n\n```dart\nimport 'package:flutter_edge_ai\u002Fflutter_edge_ai.dart';\nimport 'package:flutter_edge_ai_speech\u002Fflutter_edge_ai_speech.dart';\n\nawait FlutterEdgeAi.initialize(\n  sttBackends: [LiteRtSttBackend()],\n  ttsBackends: [LiteRtTtsBackend()],\n);\n```\n\nSpeech runs on the same native libraries as the `.litertlm` engine. Its build setup — Android `minSdk 30`, the Apple entries — is in the flutter-edge-ai-inference skill's [platform setup](..\u002Fflutter-edge-ai-inference\u002Freferences\u002Fplatform-setup.md), installed alongside this one.\n\n## Speech-to-text\n\nAn STT model is two files — the model and its tokenizer — usually from different repos. A catalog build (`LiteRtSpeechModels`, installed with `installStt().fromCatalog`) carries both, pinned to their Hugging Face commits; `install()` skips files already on disk. `FlutterEdgeAi.installStt()` installs your own files.\n\n```dart\nawait FlutterEdgeAi.installStt().fromCatalog(LiteRtSpeechModels.whisperTiny.f32)\n    .install();\n\nfinal SpeechRecognizer recognizer = await FlutterEdgeAi.getActiveStt(language: 'de');\ntry {\n  final String german = await recognizer.transcribe(germanPcm);\n  final String french = await recognizer.transcribe(frenchPcm, language: 'fr');\n} finally {\n  await recognizer.close();\n}\n```\n\n| `SttModelType` | Languages | Window |\n| --- | --- | --- |\n| `SttModelType.moonshine` | English | 5 s |\n| `SttModelType.whisper` | 99, selectable, default `'en'` | 30 s |\n| `SttModelType.parakeet` | English | 5 s; f32 is 2.35 GB, for desktop — on a Galaxy S23 (8 GB) its GPU load was killed. On a phone use the int8 `parakeet_ctc_0.6b_5s_i8.tflite` (596 MB) on the CPU (#747) |\n\nOn the GPU, run the f32 files: on Adreno 740 the int8 (`_i8`) ones did not compile there, and the load fails with an error naming the file.\n\n**Audio longer than the window is silently truncated**, not rejected: it is zero-padded when shorter and cut when longer, so a 40-second clip on Whisper returns the first 30 seconds with no error. Split long recordings yourself.\n\nWhisper tiny is weak outside English. Whisper base int8 is the next size up in the catalog: `LiteRtSpeechModels.whisperBase.i8`. Every speech build and where it has been run: https:\u002F\u002Fflutteredge.ai\u002Fdocs\u002Fregistry.\n\n## Getting 16 kHz mono PCM\n\nThe package has no resampler and no WAV reader. Record in the right format from the start — with the `record` package:\n\n```dart\nimport 'package:record\u002Frecord.dart';\n\nconst config = RecordConfig(\n  encoder: AudioEncoder.wav,\n  sampleRate: 16000,\n  numChannels: 1,\n);\n```\n\nRecording needs microphone access. On Android `record` declares `android.permission.RECORD_AUDIO` in its own manifest and the manifest merger adds it to the app; iOS and macOS need entries of your own:\n\n```xml\n\u003C!-- ios\u002FRunner\u002FInfo.plist and macos\u002FRunner\u002FInfo.plist -->\n\u003Ckey>NSMicrophoneUsageDescription\u003C\u002Fkey>\n\u003Cstring>Speech is transcribed on this device.\u003C\u002Fstring>\n\n\u003C!-- macos\u002FRunner\u002FDebugProfile.entitlements and macos\u002FRunner\u002FRelease.entitlements -->\n\u003Ckey>com.apple.security.device.audio-input\u003C\u002Fkey>\n\u003Ctrue\u002F>\n```\n\nThe macOS sandbox withholds the microphone without the entitlement, and it has to be in both entitlements files. On Android, iOS and macOS the user must also allow it at run time; `hasPermission()` asks, so call it before recording:\n\n```dart\nfinal recorder = AudioRecorder();\nif (!await recorder.hasPermission()) return;\n```\n\nThat produces a WAV file. Its header is not always 44 bytes — take the samples from the `data` chunk:\n\n```dart\nimport 'dart:typed_data';\n\n\u002F\u002F\u002F The samples of a 16 kHz mono 16-bit WAV file, without its header.\nUint8List pcmFromWav(Uint8List wav) {\n  final view = ByteData.sublistView(wav);\n  var offset = 12; \u002F\u002F after 'RIFF', the size and 'WAVE'\n  while (offset + 8 \u003C= wav.length) {\n    final id = String.fromCharCodes(wav, offset, offset + 4);\n    final size = view.getUint32(offset + 4, Endian.little);\n    final start = offset + 8;\n    if (id == 'data') {\n      final end = start + size > wav.length ? wav.length : start + size;\n      return Uint8List.sublistView(wav, start, end);\n    }\n    offset = start + size + (size & 1); \u002F\u002F chunks are padded to an even size\n  }\n  throw const FormatException('WAV file has no data chunk');\n}\n```\n\nA file recorded at another rate or channel count — 44.1 kHz stereo, say — has to be converted first: average the channels to mono, then resample with a low-pass filter. Dropping samples instead aliases and costs accuracy.\n\n## Traps\n\n**Transcript comes back in English**\n- Symptom: German audio, fluent English text, no error.\n- Cause: Whisper's language token decides the output language, not what it understands — with `'en'` it translates. moonshine only ever produces English.\n- Fix: use Whisper and pass `language:`.\n\n**A language is rejected**\n- Whisper codes are bare and lowercase: `'de'`, not `'de-DE'`, `'DE'` or `'german'`. Malformed codes throw `ArgumentError` from `getActiveStt`.\n- A well-formed code the installed checkpoint lacks (e.g. `'zz'`) throws `ArgumentError` from `transcribe`.\n\n## Text-to-speech\n\n```dart\nawait FlutterEdgeAi.installTts().fromCatalog(LiteRtSpeechModels.matchaTts.bundle)\n    .install();\n\nfinal SpeechSynthesizer synth = await FlutterEdgeAi.getActiveTts();\ntry {\n  final audio = await synth.synthesize('Hello world.'); \u002F\u002F 16-bit PCM\n  final rate = synth.sampleRate;                        \u002F\u002F 22050 for Matcha\n} finally {\n  await synth.close();\n}\n```\n\n| `TtsModelType` | Languages |\n| --- | --- |\n| `TtsModelType.matcha` | English, fixed by the installed bundle — it ignores `language:` |\n| `TtsModelType.qwen3` | `chinese`, `english`, `german`, `italian`, `portuguese`, `spanish`, `japanese`, `korean`, `french`, `russian`, or `auto` |\n| `TtsModelType.inflect` | English |\n\n`TtsModelType.supertonic` and `TtsModelType.kokoro` are in the enum but throw `UnimplementedError` — do not use them.\n\nTo ship the voice with the app instead of downloading it, swap `fromNetwork` for one of:\n\n| Call | Expects | Notes |\n| --- | --- | --- |\n| `fromAsset('assets\u002Ftts\u002Fmatcha\u002F')` | Flutter asset directory laid out like the HF repo | Declare every subdirectory in `pubspec.yaml` (Qwen3 has `tables\u002F` and `voices\u002F`); copied into app storage |\n| `fromFile('\u002Fabs\u002Fdir')` | Directory on disk, same layout | Used in place and stays the app's — `uninstallTts()` leaves these files |\n| `fromBundled()` | Native resources named `\u003Ctype>__\u003Cfile>`, e.g. `matcha__config.json` | Android `assets\u002Fmodels\u002F`, iOS Runner target; Android and iOS only |\n\nInflect's four Matcha G2P files go next to its own two. A missing file fails `install()` with the full list before the current voice is replaced; a switch that fails partway (lost connection) leaves no voice active, so `getActiveTts` throws until `install()` is run again. `install()` throws `UnsupportedError` on web. To ship a changed voice in an app update, use a new asset directory (a bundled voice refreshes itself); with `fromFile` on iOS, call `install()` at launch, because the data directory moves on update.\n\nSwitching the Qwen3 language — full lowercase names, not ISO codes, and only with the Qwen3 bundle installed (Matcha still throws the same `StateError` but the language changes nothing):\n\n```dart\nfinal english = await FlutterEdgeAi.getActiveTts(language: 'english');\nawait english.close();\nfinal german = await FlutterEdgeAi.getActiveTts(language: 'german');\n```\n\nWithout the `close()`, the second call throws `StateError: Active TTS synthesizer was created for language 'english'; call close() before requesting 'german'.`\n\n## Voice assistant\n\n`VoiceSession` runs one push-to-talk turn: transcribe, generate, speak, with barge-in. It uses the recognizer's current language.\n\nWrap the loop in `try`\u002F`catch`: a failed stage — transcribe, generate or synthesize — arrives as a **stream error**, not as an event. `VoiceErrorEvent` is reserved in this release and never emitted; the `case` is only there because the switch must be exhaustive. To barge in, call `await voice.interrupt()` — cancelling the subscription is not a portable stop.\n\n```dart\nfinal reply = StringBuffer();\nfinal voice = VoiceSession.fromChat(\n  recognizer: await FlutterEdgeAi.getActiveStt(language: 'de'),\n  chat: chat,\n  synthesizer: await FlutterEdgeAi.getActiveTts(),\n);\n\nawait for (final event in voice.runTurn(pcm16kMono)) {\n  switch (event) {\n    case VoiceTranscriptEvent(:final text):\n      print('heard: $text');\n    case VoiceReplyTextEvent(:final chunk):\n      reply.write(chunk);\n    case VoiceReplyAudioEvent(:final sampleRate):\n      print('audio at $sampleRate Hz');\n    case VoiceTurnInterruptedEvent():\n      print('interrupted — stop the player');\n    case VoiceTurnCompleteEvent():\n      print('done');\n    case VoiceErrorEvent(:final error):\n      print('failed: $error');\n  }\n}\n```\n\n`chat` is an `InferenceChat` from the flutter-edge-ai-inference skill. A chat created with tools also needs `onToolCall:` — without it `fromChat` throws.\n\n### Audio turns: no speech-to-text\n\nA model that hears audio (Gemma 4 or Gemma 3n E2B\u002FE4B as `.litertlm`, native platforms only) can take the recording itself: `runAudioTurn` skips the transcription and sends the PCM to the chat. Set `supportAudio: true` on `getActiveModel`, which loads the audio encoder; `openChat` takes the flag from the model unless you pass it, and on a chat whose `supportAudio` is false `runAudioTurn` throws `StateError`. It takes the same 16 kHz mono 16-bit PCM as `runTurn`, and wraps it in a WAV header, because a `.litertlm` model decodes an audio file; a custom `VoiceResponder.respondToAudio` gets that WAV and can pass it to `AgentSession.ask(audioBytes:)` as is. There is no `VoiceTranscriptEvent`, the complete and interrupted events carry an empty transcript, and a recording under 2 bytes completes without asking the model. After a barge-in, a stopped partial exchange remains in chat history; current LiteRT-LM recovery either rewinds it or rebuilds from full message history, including earlier audio, so the next turn does not forget that media. Requires `flutter_edge_ai_speech` 0.5.7 or later.\n\n```dart\nfinal model = await FlutterEdgeAi.getActiveModel(\n  maxTokens: 4096,\n  supportAudio: true,\n);\nfinal chat = await model.openChat(supportAudio: true, maxOutputTokens: 128);\nfinal voice = VoiceSession.fromChat(\n  recognizer: recognizer,\n  chat: chat,\n  synthesizer: synth,\n);\n\ntry {\n  await for (final event in voice.runAudioTurn(pcm16kMono)) {\n    if (event is VoiceReplyTextEvent) print(event.chunk);\n  }\n} finally {\n  await chat.close();\n}\n```\n",{"name":5,"description":7},"main","723097aedd62adb1c52163fffe85259640c7f4fd","packages\u002Fflutter_edge_ai\u002Fskills\u002Fflutter-edge-ai-speech",180,"https:\u002F\u002Fgithub.com\u002FDenisovAV\u002Fflutter_edge_ai","https:\u002F\u002Fflutteredge.ai","https:\u002F\u002Fgithub.com\u002FDenisovAV","Sasha is Flutter, Dart, Firebase and AI GDE, Co-organizer of Flutter Berlin Community, Expert in On-Device AI","2026-11-14 22:02:12",{"source":8,"skillName":5,"commands":59,"prompt":69,"zipAvailable":70},[60,63,66],{"tool":61,"command":62},"npx","npx skills add DenisovAV\u002Fflutter_edge_ai --skill flutter-edge-ai-speech",{"tool":64,"command":65},"bunx","bunx skills add DenisovAV\u002Fflutter_edge_ai --skill flutter-edge-ai-speech",{"tool":67,"command":68},"pnpm","pnpm dlx skills add DenisovAV\u002Fflutter_edge_ai --skill flutter-edge-ai-speech","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FDenisovAV\u002Fflutter_edge_ai\u002Fblob\u002Fmain\u002Fpackages\u002Fflutter_edge_ai\u002Fskills\u002Fflutter-edge-ai-speech\u002FSKILL.md",true,[],[73,86,97,113,130,143],{"skillNo":74,"name":75,"nameZh":6,"description":76,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":77,"categories":78,"keywords":82,"publishedAt":44},"01M6BXTT3TADZ7NN5RY79ZZKDR","send-email","Send an email.","https:\u002F\u002Fgithub.com\u002FDenisovAV\u002Fflutter_edge_ai\u002Fblob\u002Fmain\u002Fpackages\u002Fflutter_edge_ai_agent\u002Fassets\u002Fskills\u002Fsend-email\u002FSKILL.md",[79],{"categoryNo":80,"categoryName":81,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000005","邮件与沟通",[83,84,85],"send","send email","email",{"skillNo":87,"name":88,"nameZh":6,"description":89,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":90,"categories":91,"keywords":92,"publishedAt":44},"01M6BXTQPW2BAVZ2SRVTMFF9FA","query-wikipedia","Query summary from Wikipedia for a given topic.","https:\u002F\u002Fgithub.com\u002FDenisovAV\u002Fflutter_edge_ai\u002Fblob\u002Fmain\u002Fpackages\u002Fflutter_edge_ai_agent\u002Fassets\u002Fskills\u002Fquery-wikipedia\u002FSKILL.md",[],[93,94,95,29,96],"wikipedia","query","query wikipedia","summary",{"skillNo":98,"name":99,"nameZh":6,"description":100,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":101,"categories":102,"keywords":108,"publishedAt":44},"01M6BXTN6C4R4FZ5T9GRNY5MFG","qr-code","Generates a QR code for the given url.","https:\u002F\u002Fgithub.com\u002FDenisovAV\u002Fflutter_edge_ai\u002Fblob\u002Fmain\u002Fpackages\u002Fflutter_edge_ai_agent\u002Fassets\u002Fskills\u002Fqr-code\u002FSKILL.md",[103],{"categoryNo":104,"categoryName":105,"taxonomyType":106,"taxonomyTypeDesc":107},"01JBSEEDCAT000000000000030","开发工程师","PROFESSION","适用职业",[109,110,111,29,112],"qr","qr code","code","URL",{"skillNo":114,"name":115,"nameZh":6,"description":116,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":117,"categories":118,"keywords":119,"publishedAt":44},"01M6BXTJXNJNW59BV5JM3V9YZD","kitchen-adventure","Act as a dungeon master for a text-based adventure set in a world where everyone is a sentient kitchen appliance. Trigger when user says \"start kitchen adventure\".","https:\u002F\u002Fgithub.com\u002FDenisovAV\u002Fflutter_edge_ai\u002Fblob\u002Fmain\u002Fpackages\u002Fflutter_edge_ai_agent\u002Fassets\u002Fskills\u002Fkitchen-adventure\u002FSKILL.md",[],[120,34,121,29,122,123,124,125,126,127,40,128,129],"kitchen adventure","dungeon master","trigger","as","act","world","master","user","SET","start",{"skillNo":131,"name":132,"nameZh":6,"description":133,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":134,"categories":135,"keywords":136,"publishedAt":44},"01M6BXTGEPGG025VBEQKPJZB8S","interactive-map","Show an interactive map view for the given location.","https:\u002F\u002Fgithub.com\u002FDenisovAV\u002Fflutter_edge_ai\u002Fblob\u002Fmain\u002Fpackages\u002Fflutter_edge_ai_agent\u002Fassets\u002Fskills\u002Finteractive-map\u002FSKILL.md",[],[137,138,139,140,141,142,29],"interactive map","interactive","map","view","show","location",{"skillNo":144,"name":145,"nameZh":6,"description":146,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":147,"categories":148,"keywords":149,"publishedAt":44},"01M6BXTED45RFKX4EYF9BSWC7H","get-current-time","Get the user's current local date, time, and day of the week.","https:\u002F\u002Fgithub.com\u002FDenisovAV\u002Fflutter_edge_ai\u002Fblob\u002Fmain\u002Fpackages\u002Fflutter_edge_ai_agent\u002Fassets\u002Fskills\u002Fget-current-time\u002FSKILL.md",[],[150,151,152,153,127,154],"current time","get current time","time","get","local"]