Skip to main content

Wave Chunk Parser

Parses wave files chunks in order to extract metadata and audio. Also provides an option to write a bunch of given chunks back into a coherent file.

Installation

pip install wave-chunk-parser

Reading a file / IO stream

from wave_chunk_parser.chunks import RiffChunk

with open("file.wav", "rb") as file:
    riff_chunk = RiffChunk.from_file(file)

From there you can access the sub chunks from riff_chunk.sub_chunks. The data chunk uses a numpy array to hold the vectors of audio samples.

Format (fmt) and data chunks are critical. Cart chunk is optional but provides those markers we need for handling broadcast audio.

Writing a file / IO stream

You will need to build the chunks individually and supply them in a list of:

chunks = [FormatChunk, DataChunk, CartChunk]

The format chunk must come before the data chunk (we need to know how to en/decode it). Cart chunk can appear anywhere in the list or even not exist at all.

To get a blob for writing to disk (or wherever), simply:

riff_chunk = RiffChunk(chunks)
blob = riff_chunk.to_bytes()

The to_bytes function exists on every chunk type. So, if you particularly desire, you can turn a standalone format chunk into a blob.

Numpy on macOS

We need openblas to make Numpy work on macOS:

pip uninstall numpy
brew install openblas
OPENBLAS="$(brew --prefix openblas)" pip install numpy --no-cache-dir

Building the package for deployment

To build the package for deployment:

poetry run python setup.py sdist bdist_wheel
poetry run twine upload --repository testpypi dist/*

Release files for wave-chunk-parser 1.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for wave-chunk-parser 1.5.0
File Interpreter ABI Platform
wave_chunk_parser-1.5.0-py3-none-any.whl Python 3 none any Details

Release files / wave_chunk_parser-1.5.0-py3-none-any.whl

Download URL wave_chunk_parser-1.5.0-py3-none-any.whl
Size 35.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fb43995bdfa30c37d25078c65e525a903e362e9eecb0d73b6dcae24cdb92b35f
BLAKE2b-256 checksum
How to use checksums
1d8ca0eaec01556063eb83ba62f933da047a43595e3c73f741576e02556a9cf0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.12.2

Release history Release notifications | RSS feed

This release

1.5.0 This release

1 release file

1.4.2

2 release files

1.4.1

2 release files

1.4.0

2 release files

1.3.0

2 release files

1.2.2

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page