Skip to content

info

Read a file’s stream parameters from the header, without decoding any audio. Works on paths and on bytes, for every supported format.

specux.audio.info(path, *, track=0)
nfo = specux.audio.info("song.m4a")
nfo.frames, nfo.samplerate, nfo.channels, nfo.format, nfo.tracks
nfo.duration # seconds, frames / samplerate
  • track: which audio stream to describe in a multi-track container; tracks on the result says how many there are.
  • Frame counts for lossy formats come from the container and can be off by a priming/padding block; the decoded array from load is the exact truth.

Use it to size buffers, filter a corpus by sample rate, or pick a track before committing to a full decode.