Skip to main content

earshot_capture 1.0.0 copy "earshot_capture: ^1.0.0" to clipboard
earshot_capture: ^1.0.0 copied to clipboard

On-device microphone capture for Flutter as a float32 PCM stream, with permission status. No network.

earshot_capture #

pub package style: very good analysis License: MIT

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 NSMicrophoneUsageDescription to Info.plist. On macOS, also add the com.apple.security.device.audio-input entitlement.
  • Android: RECORD_AUDIO is merged into your app's manifest by earshot_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() reports interrupted during phone calls, Siri or input device changes. Capture resumes on its own.
  • The input is unprocessed where the platform allows it: the iOS .measurement mode, and Android's UNPROCESSED source with a VOICE_RECOGNITION fallback.
0
likes
160
points
381
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

On-device microphone capture for Flutter as a float32 PCM stream, with permission status. No network.

Repository (GitHub)
View/report issues
Contributing

Topics

#audio #microphone #pcm

License

MIT (license)

Dependencies

earshot_capture_android, earshot_capture_darwin, earshot_capture_platform_interface, flutter

More

Packages that depend on earshot_capture

Packages that implement earshot_capture