AudioCaptureManager class

Manages audio capture from microphone for STT services.

This is a shared utility that works with any STT backend (ONNX, WhisperKit, etc.). It captures audio at 16kHz mono Int16 format, which is the standard input format for speech recognition models like Whisper.

Matches iOS AudioCaptureManager from Features/STT/Services/AudioCaptureManager.swift

Usage

final capture = AudioCaptureManager();
final granted = await capture.requestPermission();
if (granted) {
  await capture.startRecording((audioData) {
    // Feed audioData to your STT service
  });
}

Constructors

AudioCaptureManager()

Properties

audioLevel double
Current audio level (0.0 to 1.0)
no setter
audioLevelStream Stream<double>
Stream of audio level updates (0.0 to 1.0)
no setter
hashCode int
The hash code for this object.
no setterinherited
isRecording bool
Whether audio is currently being recorded
no setter
recordingStateStream Stream<bool>
Stream of recording state changes
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

bufferToData(Int16List buffer) Uint8List
Convert audio buffer to PCM data
dispose() → void
Dispose resources
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onAudioDataAvailable(Uint8List audioData) → void
Called when audio data is available from the platform
requestPermission() Future<bool>
Request microphone permission
startRecording(void onAudioData(Uint8List audioData)) Future<void>
Start recording audio from microphone
stopRecording() Future<void>
Stop recording
toString() String
A string representation of this object.
inherited
updateAudioLevel(Float32List buffer) → void
Update audio level for visualization

Operators

operator ==(Object other) bool
The equality operator.
inherited

Constants

targetSampleRate → const int
Target sample rate for Whisper models