earshot_capture 0.2.0
earshot_capture: ^0.2.0 copied to clipboard
Pre-release: on-device microphone capture for Flutter as a float32 PCM stream, with permission status. No network.
earshot_capture #
Warning
Pre-release (0.x). The public API may still change in 0.x. See the feature checklist for what works today.
On-device microphone capture for Flutter on Android, iOS and macOS: a float32 mono PCM stream at 16, 44.1 or 48 kHz, plus the microphone permission status.
Part of earshot: on-device ambient listening with no network access, where no audio leaves the device.
Microphone setup #
Your app declares microphone access, not this package:
- iOS and macOS: add
NSMicrophoneUsageDescriptiontoInfo.plist. On macOS, also add thecom.apple.security.device.audio-inputentitlement. - Android:
RECORD_AUDIOis merged into your app's manifest byearshot_capture_android. Your app still asks the user at runtime.
Usage #
import 'package:earshot_capture/earshot_capture.dart';
final status = await const MicrophonePermission().request();
if (status != MicrophonePermissionStatus.granted) return;
final subscription = const EarshotCapture()
.pcm(config: const CaptureConfig(sampleRate: SampleRate.hz48000))
.listen(
(chunk) => debugPrint('${chunk.samples.length} samples'),
onError: (Object error) => debugPrint('$error'), // a CaptureException
);
// Cancelling the last subscription closes the microphone.
await subscription.cancel();
- Concurrent subscriptions share one microphone session and must use the same sample rate.
stateChanges()reportsinterruptedduring phone calls, Siri or input device changes. Capture resumes on its own.- The input is unprocessed where the platform allows it: the iOS
.measurementmode, and Android'sUNPROCESSEDsource with aVOICE_RECOGNITIONfallback.