earshot_classifier_darwin 0.1.0
earshot_classifier_darwin: ^0.1.0 copied to clipboard
Pre-release: the iOS and macOS implementation of earshot_classifier, backed by Apple's on-device SoundAnalysis.
earshot_classifier_darwin #
Warning
Pre-release (0.x). The public API may still change in 0.x. See the feature checklist for what works today.
The iOS and macOS implementation of earshot_classifier, backed by Apple's on-device SoundAnalysis (iOS 15+, macOS 12+). It is endorsed, so apps should depend on earshot_classifier and get this package automatically.
Part of earshot: on-device ambient listening with no network access, where no audio leaves the device.
How it works #
- Each
listen()ondetections()starts its own session, with its ownSNAudioStreamAnalyzerandSNClassifySoundRequest(classifier version 1). Sessions that run at the same time share oneAVAudioEngineinput tap, and the microphone is released when the last one is cancelled. - Every label of an analysis window (about one second, overlapping by half) at or above the minimum confidence is reported. Labels are mapped to
EarshotSoundandSoundGroupin Dart, withSoundVocabulary. isAvailable()never prompts, and neither does classification: request the microphone permission first, for example withEarshotCapture.requestMicrophonePermission(). Without it, the stream fails withCaptureException(CaptureErrorCode.permissionDenied).- On iOS the audio session uses the
.recordcategory and the.measurementmode. Interruptions (calls, Siri, route and device changes) pause the detections, which resume on their own afterwards. - No audio is written to disk or leaves the device.
Minimum OS versions #
Sound classification on Apple platforms uses SoundAnalysis, so apps that depend on this package need iOS 15 or macOS 12 or later.
Microphone setup #
Your app declares microphone access, not this package: add NSMicrophoneUsageDescription to Info.plist, and on macOS also add the com.apple.security.device.audio-input entitlement.
Disclaimer #
earshot is informational and is not a certified detector. Never rely on it for safety, including smoke and carbon monoxide alarms.