This package provides a simple and unified API to read and write sound-files to and from numpy arrays.
Documentation
API
sndread
reads all the samples (or a fragment) from a soundfile and returns a tuplet (data, samplerate)
Data will always be as a numpy.float64, between -1 and 1, independently of bit-rate
sndread_chunked
reads chunks of frames, avoiding the allocation of all the samples in memory
sndinfo
returns SndInfo, a namedtuple with all the information of the sound-file
sndwrite
writes the samples.
samples need to be a numpy.float64 array with data between -1 and 1
sndwrite_chunked
allows you to write to the file as samples become available
resample
Resample a numpy array to a new samplerate
Examples
# Normalize and save as flac
from sndfileio import sndread, sndwrite
samples, sr = sndread("in.wav")
maxvalue = max(samples.max(), -samples.min())
samples *= 1/maxvalue
sndwrite(samples, sr, "out.flac")
# Process a file in chunks
from sndfileio import *
from sndfileio.dsp import
with sndwrite_chunked(44100, "out.flac") as writer:
for buf in sndread_chunked("in.flac"):
# do some processing, like changing the gain
buf *= 0.5
writer.write(buf)
Installation
pip install sndfileio
External dependencies
libsndfile (Debian/Ubuntu: apt install libsndfile1-dev)
License
See the LICENSE file for license rights and limitations (MIT).
Metadata
Release files for sndfileio 2.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| sndfileio-2.1.2.tar.gz | 1.9 MB | Without provenance | Details for sndfileio-2.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sndfileio-2.1.2-py3-none-any.whl | Python 3 | none | any | Details for sndfileio-2.1.2-py3-none-any.whl |
Total release size: 2.7 MB
Release files / sndfileio-2.1.2.tar.gz
| Download URL | sndfileio-2.1.2.tar.gz |
|---|---|
| Size | 1.9 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
659c5ab4ce094375bfddb51a7aef82de480c8356fe7ab02349de6e0ceade9ac6
|
|
BLAKE2b-256 checksum How to use checksums |
addfde22355942ac1b2e20bf5e520e33465b48d4b425d9b28497b00cb9da1c88
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.7.2
|
Release files / sndfileio-2.1.2-py3-none-any.whl
| Download URL | sndfileio-2.1.2-py3-none-any.whl |
|---|---|
| Size | 744.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
58f5a4fad5d4c0e4c99a64ff2bbdedb9081a2060fc6b1d51fcf2d6461d36f415
|
|
BLAKE2b-256 checksum How to use checksums |
0425885edfa8881bfd67373639b3b543b2d6502643f6602a43992e35d7e8d679
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.7.2
|
Security for sndfileio 2.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.