Documentation
¶
Overview ¶
Package audioio converts a local audio (or video) file into the 16 kHz mono 16-bit PCM WAV that whisper.cpp expects, using ffmpeg. It drops any video stream (-vn) so a video source only ships its audio downstream, and NEVER fetches a remote URL — only local files. Mirrors internal/videoio.
Index ¶
Constants ¶
This section is empty.
Variables ¶
ErrFFmpegUnavailable is what a conversion returns when ffmpeg could not be run at all (the executable is not on the PATH, the configured path is wrong or not executable), as opposed to ffmpeg running and refusing the input. The first is the stack's fault and the second the caller's file: a ledger row that filed both as "bad input" (F22 follow-up) would send an operator to look at a file when the box has no ffmpeg. errors.Is(err, ErrFFmpegUnavailable) lets a door file it as ffmpeg_unavailable.
var ErrNoAudioStream = errors.New("the input has no audio stream")
ErrNoAudioStream is what a conversion returns for an input that has no audio stream to convert: a silent screen recording, a video without a track, a picture. ffmpeg's own words for it are "Output file does not contain any stream" with exit status 234 (the output has nothing to hold once -vn has dropped the video), which read as an ffmpeg failure to everything above this package (F21, 2026-10-09: a transcription deferred with that raw text). It is a fact about the caller's file, not about ffmpeg or the stack: errors.Is(err, ErrNoAudioStream) lets a door say so and file it as a bad input.
Functions ¶
func ConvertToOpus16k ¶ added in v0.206.0
ConvertToOpus16k transcodes audioPath to a 16 kHz mono Opus/Ogg file at about 32 kbps in a fresh temp dir and returns its path plus a cleanup func that removes the dir (safe to call twice). It is the form a transcription travels in to a fleet node (the stt upload door): about 14 MB per hour of speech where the 16 kHz WAV the local path feeds whisper is 115 MB. ffmpegPath is the ffmpeg executable ("" => "ffmpeg"). A missing input or an ffmpeg failure (a build without libopus included) returns an error and leaves nothing behind; the caller may then send the original file.
func ConvertToWav16k ¶
ConvertToWav16k transcodes audioPath to a 16 kHz mono PCM WAV in a fresh temp dir and returns the wav path plus a cleanup func that removes the temp dir. ffmpegPath is the ffmpeg executable ("" => "ffmpeg"). The caller MUST defer cleanup() (it is also safe to call twice). A missing input or an ffmpeg failure returns an error and leaves nothing behind.
Types ¶
This section is empty.