stt_recorder 0.1.0+1
stt_recorder: ^0.1.0+1 copied to clipboard
Single pipeline voice capture + STT bridge
stt_recorder #
A federated Flutter plugin that captures audio and streams partial speech-to-text updates from the same capture session.
Why this package #
stt_recorder is designed for flows where you need to:
- record audio for upload/training,
- highlight script text in real time with partial STT,
- stop once and get a final capture artifact.
Features #
- Single public API with
start,partialTextStream,stop, andcancel. - Returns a
VoiceCaptureArtifactonstop. - Streams partial transcript text during capture on Android, iOS, and macOS.
- Supports browser recording on web.
- Locale-aware start (
localeId). - Endorsed Android, iOS, macOS, and web implementations.
Installation #
dependencies:
stt_recorder: ^0.1.0
Platform setup #
Android #
Ensure microphone permission exists (usually merged from plugin manifest):
<uses-permission android:name="android.permission.RECORD_AUDIO" />
Request microphone permission before calling start.
iOS #
Add to Info.plist:
NSMicrophoneUsageDescriptionNSSpeechRecognitionUsageDescription
Request microphone/speech permissions before calling start.
macOS #
Add to macos/Runner/Info.plist:
NSMicrophoneUsageDescriptionNSSpeechRecognitionUsageDescription
Web #
- Run in a secure context (
httpsorlocalhost). - Call
startfrom a user gesture after the browser grants microphone access. - Web currently records audio and emits
__speech_unavailable__so callers can fall back to non-STT UI behavior.
Usage #
import 'dart:async';
import 'package:stt_recorder/stt_recorder.dart';
StreamSubscription<String>? subscription;
Future<void> begin() async {
subscription = SttRecorder.partialTextStream().listen((partial) {
// Update your text highlighter.
print(partial);
});
await SttRecorder.start(localeId: 'en-US');
}
Future<VoiceCaptureArtifact> end() async {
final artifact = await SttRecorder.stop();
await subscription?.cancel();
debugPrint('Saved ${artifact.fileName} as ${artifact.mimeType}');
debugPrint('Native path: ${artifact.path ?? '(in-memory only)'}');
return artifact;
}
Future<void> abort() async {
await SttRecorder.cancel();
await subscription?.cancel();
}
Event markers #
The stream can emit special marker strings:
__speech_unavailable____speech_error__:<code>
Treat these as control signals (not transcript words).
On web, __speech_unavailable__ is expected today because the implementation
records audio without browser STT transcription.
API reference #
SttRecorder.start({required String localeId})SttRecorder.partialTextStream()SttRecorder.stop()->Future<VoiceCaptureArtifact>SttRecorder.cancel()
Artifact fields #
VoiceCaptureArtifact contains:
bytes: captured audio bytesfileName: best-effort output namemimeType: MIME type for upload or persistencepath: optional native file path when the platform writes to disk
Publishing notes #
Before publishing:
- Run format, tests, analyze, and
flutter pub publish --dry-runin all federated packages. - Publish from a clean package directory without local
pubspec_overrides.yamlfiles so validation runs against hosted versions of sibling packages. - Verify iOS podspec metadata/license are correct.
- Validate example app on Android, iOS, macOS, and web.
- For automated publishing, configure pub.dev trusted publishing to use
workflow
publish_stt_recorder.yaml, environmentpub.dev, and tag patternstt_recorder-v{{version}}.
License #
BSD-3-Clause (see platform package licenses where applicable).