flutter_ai_voice 0.1.1
flutter_ai_voice: ^0.1.1 copied to clipboard
Speech-to-text contracts and models for flutter_ai: a batch-first SpeechToText interface, transcript models, and a callback adapter. Concrete engines (Whisper and friends) plug in behind the interface.
flutter_ai_voice #
☕ Support this project #
If flutter_ai saves you time, buy me a coffee ☕ — it keeps the whole family maintained.

Speech-to-text contracts and models for the flutter_ai
family. Dependency-free; concrete engines plug in behind the interface.
Scope — what this package is not #
This package is speech-to-text contracts only. So you know up front, it does not include:
- No audio capture / recording. You record the audio (e.g. with
record,flutter_sound, or the platform mic) and hand the bytes/file to aSpeechToText. - No text-to-speech (TTS). Nothing here speaks responses aloud. Wire a TTS
engine yourself (e.g.
flutter_tts) and drive theonSpeakhook onAiMessageActions. - No bundled STT engine.
SpeechToTextis an interface — bring on-device Whisper, a cloud API, or the platform recognizer. AiLiveSession(influtter_ai_elements) is presentational. The orb, transcript, and amplitude reaction are UI; you connect the mic + aSpeechToTextbehind it.transcribeStreamis best-effort, not true live STT.CallbackSpeechToTextin particular buffers the whole stream in memory and emits nothing until it closes — see its dartdoc. Prefer the record-then-transcribe flow below.
Why batch-first #
Native OS speech recognition has awkward limits (iOS cuts off after ~1 minute),
so the reliable flow is: record → transcribe a finished buffer → send the
text. Continuous transcribeStream is offered for live captions but is
best-effort.
API #
SpeechToText—transcribeBytes,transcribeFile,transcribeStream.Transcript/TranscriptSegment/TranscriptPartial— result models.CallbackSpeechToText— wrap any transcribe function without a full class.
Usage #
import 'package:flutter_ai_voice/flutter_ai_voice.dart';
// Adapt any engine (on-device Whisper, a cloud API, …) in one line:
final stt = CallbackSpeechToText(
transcribe: (audio, {mediaType, language}) => myWhisper.run(audio),
);
final transcript = await stt.transcribeBytes(recordedBytes);
controller.sendText(transcript.text); // feed into flutter_ai_client
Plugging in a real engine #
Implement SpeechToText directly, or pass a function to CallbackSpeechToText.
On-device options like whisper_ggml/whisper_kit and cloud services are
intentionally not dependencies here, so the package stays light — wire your
chosen engine in the host app or a dedicated adapter package.
Status #
0.1.1. Interface + models + callback adapter, fully unit-tested. No concrete
audio engine, recording, or TTS ships in this package (see Scope above).
