live-dictation

command
v0.6.21 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 4, 2026 License: MIT Imports: 14 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

live-dictation

Zero-cgo macOS on-device speech recognition and full-duplex barge-in voice control built on x/ondeviceasr (speech.SFSpeechRecognizer, avfaudio.AVAudioPCMBuffer) and x/duplexaudio.

What it does

  1. Probes SFSpeechRecognizer capabilities (IsAvailable, SupportsOnDeviceRecognition, AuthorizationStatus, native sample rate, supported locales) and x/duplexaudio host audio capabilities without triggering an interactive TCC permission modal.
  2. Synthesizes a 16 kHz PCM16 speech fixture with macOS say (falling back to a 440 Hz tone fixture if say is unavailable).
  3. Runs the AVAudioPCMBuffer -> SFSpeechAudioBufferRecognitionRequest streaming bridge and x/duplexaudio full-duplex barge-in controller (keyword + RMS energy flush-to-silence).
  4. When Speech Recognition TCC is authorized, runs live on-device TranscribeFile and streaming StartStream recognition on the fixture or a user-supplied -file. When denied/not_determined/restricted, reports the TCC status honestly without hanging.

Usage

CGO_ENABLED=0 go run ./examples/speech/live-dictation

Flags:

  • -locale (default en-US): BCP-47 locale identifier
  • -demo (default true): run the self-contained fixture + barge-in demo
  • -file: optional WAV/AIFF/M4A file to transcribe on-device
  • -phrase: spoken phrase synthesized in -demo mode
  • -keywords (default stop,cancel,hold on): comma-separated barge-in keywords
  • -timeout (default 15s): overall timeout

Measured Output (macOS arm64, CGO_ENABLED=0)

$ CGO_ENABLED=0 go run ./examples/speech/live-dictation
== Host Probe ==
speech.locale            : en-US
speech.available         : true
speech.supports_on_device: true
speech.auth_status       : denied
speech.native_sample_rate: 16000 Hz
speech.supported_locales : 63
audio.devices            : 4 (in=true out=true mic_auth=authorized)
audio.voice_processing_io: true (workgroup=true)

== Audio Fixture ==
source     : macOS say (LEI16@16000)
sample_rate: 16000 Hz
samples    : 47193 (2.95s)
rms        : 0.0998

== On-Device ASR & Barge-In Pipeline ==
asr_status : not_authorized (Speech TCC=denied); live recognition skipped without prompting
asr_hint   : grant Speech Recognition permission to run live SFSpeechRecognizer tasks
pcm_bridge : appended 30 AVAudioPCMBuffer chunks (47193 frames) to SFSpeechAudioBufferRecognitionRequest
barge_in   : reason=keyword keyword="stop" flush_latency=18.001667ms queued_before=2048 queued_after=0
barge_in   : reason=energy rms=0.0998 flush_latency=831.5µs queued_before=2048 queued_after=0

== Duplex Engine Stats ==
mode=loopback workgroup=true callbacks=5 barge_ins=2 last_flush=831.5µs max_flush=18.001667ms

Documentation

Rendered for darwin/amd64

Overview

Command live-dictation demonstrates zero-cgo on-device speech recognition with Apple's Speech framework (x/ondeviceasr), AVAudioPCMBuffer streaming, and full-duplex barge-in voice control (x/duplexaudio).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL