waveinfo - A wave file reader for python

waveinfo is a python package for parsing details about wave audio files.

Usage

Usage is fairly straightfoward. Initialise a WavFile with any of:

  • A string or PathLike pointing to the wave file in question.
  • A binary file object containing the file.
  • A bytes object containing the full contents of the file.
>>> from waveinfo import WavFile
>>> wav = WavFile("path/to/file.wav")
>>> # or ...
>>> with open("path/to/file.wav", "rb") as fh:
...     wav = WavFile(fh)

The most interesting attributes of a WavFile are detail - which contains details of the wave file audio, and info - which is a dict of any metadata that may be embedded in the file.

>>> wav.detail.format
Format.PCM
>>> wav.detail.duration
datetime.timedelta(seconds=42)
>>> wav.detail.channels
1
>>> wav.detail.bit_depth
16
>>> wav.detail.sample_rate
44100
>>> wav.info
{'Software': 'Lavf61.1.100'}

If you're only interested in the details, you can initialise a WavDetail directly in the same way:

>>> from waveinfo import WavDetail
>>> details = WavDetail("path/to/file.wav")
>>> details.format
Format.PCM
>>> # etc...