Skip to content

dictation_service

diapason.desktop.dictation_service

The dictation service — the parts wired into one running thing.

Composes the four pieces of the push-to-talk stack:

hotkey (CGEventTap)  →  PTT state machine  →  mic capture  →
transcribe (speech backend)  →  clean paste (clipboard preserved)

The composition — which action leads to capture/transcribe/paste — is a pure method (_run_action) driven by injected callables, so the whole flow is testable with fakes: no microphone, no tap, no transcription model. The live wiring (start/stop) only attaches the real hotkey listener.

DictationService

Drive dictation from key events, independent of any window.

float_mono_to_wav(samples, sample_rate=16000)

Encode a float32 [-1, 1] mono array as 16-bit PCM WAV bytes (stdlib).