Skip to main content

Module audio

Module audio 

Source
Expand description

Audio capture: the sources, the recordings they write, and the canonical 16 kHz mono format shared by everything that reads them.

RecordingReader builds on every target. Everything that opens a microphone, a model, or a file is native.

Structs§

RecordedAudio
The result of a finished recording: its length and, on a target with a filesystem, its WAV. A WAV this crate wrote is deleted when its owner drops. A caller’s own file is only borrowed. A recording ended by RecordingWriter::finish has none.
Recording
What one capture’s writer and readers share: each reader’s queue of unread samples, the count written, and how capture ended. It keeps no history: a sample lives only in the queues of readers yet to take it.
RecordingReader
A window onto a recording, readable while capture is still writing it. One reader; RecordingReader::fork adds another.
RecordingWriter
The write end of a Recording.
Resampler
Converts mono f32 audio at any sample rate to canonical 16 kHz.
SilenceDuration
StopSignal
The capture-side stop check. Owned by the capture worker, which drops it the moment recording ends — owners can rely on that drop for cleanup.
Stopper
A handle that ends a recording from anywhere: clone it, hand it to a hotkey or UI, call stop().
WavReplayCapture

Enums§

CaptureError
MicrophoneError
RecordingMode
ReplayPace
How a WAV replay delivers its samples. Immediate writes the whole file before start returns. Realtime writes it at recorded speed, so transcription overlaps capture as on a real press.
ResampleError
SilenceDurationError
SpoolError
WavError
WavReplayError

Constants§

CANONICAL_SAMPLE_RATE
CHANNELS

Traits§

AudioCapture
A source of canonical 16 kHz mono audio. Each implementation bounds how long a recording runs.

Functions§

canonical_duration
How long samples canonical samples last.
canonical_samples
How many canonical samples duration spans, rounded down. Saturates at u64::MAX.
f32_from_pcm16
read_wav
Reads every sample of a canonical WAV. Unlike RecordingReader::from_wav_file, it sets no length limit.
remove_all_spools
write_wav
Writes samples to path as a canonical WAV, replacing any file there.