ptt
ptt
¶
Push-to-talk state machine — hold to dictate, double-tap for hands-free.
Pure logic: it takes key-down / key-up events with a timestamp and emits a list of actions for a host to carry out (start capture, stop and transcribe, cancel...). No microphone, no clock of its own, no threads — which is what makes the whole dictation flow unit-testable without hardware.
Behaviour mirrors Diapason's, which is the reference product:
- Hold the key, speak, release → transcribe what was said (normal PTT).
- Two quick taps → hands-free: capture keeps running after release; the next tap stops it and transcribes. The second tap of the double also cancels the tiny first session so it never produces a stray transcription.
- A tap while a normal press is somehow still held is ignored (key repeat).
cancel()throws away the in-flight audio without transcribing.