Expand description
Audio loading and conversion.
Strategy for v0.0.0:
- Prefer system
ffmpegfor decoding any common format to 16 kHz mono f32 PCM - Fail fast with install instructions if ffmpeg is missing
- WAV files that are already 16 kHz mono PCM can be read directly via
hound - Enforce duration / decoded-size bounds during decode so we fail before OOM
Remote TTS wire formats use [remote_normalize] (JOE-1937): bounded PCM/WAV
in-process, supervised FFmpeg for MP3 only.
Structs§
- Audio
Input - In-memory audio ready for a transcription provider.
- Bounded
Audio Body - Encoded provider body already under a hard byte cap.
- Normalized
Audio - Validated mono PCM result of remote-audio normalization.
- Remote
Audio Limits - Resource bounds for remote audio normalization.
Enums§
- Channel
Policy - How multi-channel PCM is handled.
- Encoded
Audio Format - Wire format declared by the provider/capability path (not raw MIME guessing).
- Ffmpeg
Termination - Structured FFmpeg termination reason (JOE-1585).
Constants§
- ALLOWED_
SAMPLE_ RATES_ HZ - Discrete sample rates accepted for remote TTS wire formats.
- DEFAULT_
FFMPEG_ TIMEOUT - Default wall-clock deadline for a single FFmpeg decode (JOE-1585).
- DEFAULT_
MAX_ DECODED_ BYTES - Approximate decoded PCM budget (f32 mono 16 kHz) — ~500 MB ≈ 2.25 h.
- DEFAULT_
MAX_ DURATION - Default maximum duration of normalized audio.
- DEFAULT_
MAX_ DURATION_ SECS - Default maximum audio duration accepted for transcription (~2.25 h matches PCM budget).
- DEFAULT_
MAX_ ENCODED_ BYTES - Default hard cap on encoded provider response bodies (16 MiB).
- DEFAULT_
MAX_ PCM_ SAMPLES - Default hard cap on decoded mono PCM sample count (~10 min @ 48 kHz).
- DEFAULT_
MAX_ UPLOAD_ BYTES - Max compressed upload size for remote providers (~24 MB keeps base64 JSON manageable).
- SUPPORTED_
EXTENSIONS - Supported input extensions (informational; ffmpeg is the real gate).
- WHISPER_
SAMPLE_ RATE - Sample rate required by the local whisper.cpp path (Hz).
Functions§
- encode_
for_ upload - Encode samples to a compressed temp file for remote upload (JOE-1648).
- encode_
for_ upload_ with_ timeout - Supervised upload encode with explicit deadline and optional cancel flag.
- ffmpeg_
available - Check whether ffmpeg is available (non-fatal).
- format_
from_ path - Infer a reasonable audio format label from a path extension.
- load_
audio - Load an audio file, converting to 16 kHz mono f32 PCM as needed.
- load_
audio_ with_ limits - Load audio with explicit safety limits (used by tests and future flags).
- load_
via_ ffmpeg_ with_ timeout - Supervised FFmpeg decode with explicit deadline and optional cancel flag.
- normalize_
remote_ audio - Normalize provider audio bytes into mono
i16PCM under shared limits. - require_
ffmpeg - Ensure ffmpeg is available on PATH.
- try_
load_ wav_ file - Attempt to read a 16 kHz mono PCM WAV directly, rejecting oversized files first.
- write_
temp_ wav - Write samples out as a 16 kHz mono WAV using an exclusive create (O_EXCL).