hear
Easy access to audio data.
To install: pip install hear
Examples
A wav serialization/deserialization transformer.
First let's make a very short waveform.
>>> from hear import WavSerializationTrans
>>> from numpy import sin, arange, pi
>>> n_samples = 5; sr = 44100;
>>> wf = sin(arange(n_samples) * 2 * pi * 440 / sr)
>>> wf
array([0. , 0.06264832, 0.12505052, 0.18696144, 0.24813785])
An instance of WavSerializationTrans will allow you to
>>> trans = WavSerializationTrans(assert_sr=sr) # if you want to write data you NEED to specify assert_sr
>>> wav_bytes = trans._data_of_obj(wf)
>>> wav_bytes[:44] # the header bytes
b'RIFF.\x00\x00\x00WAVEfmt \x10\x00\x00\x00\x01\x00\x01\x00D\xac\x00\x00\x88X\x01\x00\x02\x00\x10\x00data\n\x00\x00\x00'
>>> wav_bytes[44:] # the data bytes (5 * 2 = 10 bytes)
b'\x00\x00\x04\x08\x01\x10\xee\x17\xc2\x1f'
>>> wf_read_from_bytes = trans._obj_of_data(wav_bytes)
>>> wf_read_from_bytes
array([ 0, 2052, 4097, 6126, 8130], dtype=int16)
Note that we've serialized floats, but they were deserialized as int16. This is the default behavior, but is cusomizable through dtype, subtype, etc. With this default dtype=int16 setting though, if you serialize int16 arrays, you'll recover them exactly.
>>> assert all(trans._obj_of_data(trans._data_of_obj(wf_read_from_bytes)) == wf_read_from_bytes)
The most common use of WavSerializationTrans through, is to make a class decorator for a store that provides wav bytes.
>>> @WavSerializationTrans.wrapper(assert_sr=sr)
... class MyWavStore(dict):
... pass
>>> my_wav_store = MyWavStore(just_one=wav_bytes)
>>> my_wav_store['just_one']
array([ 0, 2052, 4097, 6126, 8130], dtype=int16)
Metadata
Release files for hear 0.1.22
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 |
|---|---|---|---|---|
| hear-0.1.22.tar.gz | 30.2 kB | Without provenance | Details for hear-0.1.22.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| hear-0.1.22-py3-none-any.whl | Python 3 | none | any | Details for hear-0.1.22-py3-none-any.whl |
Total release size: 57.6 kB
Release files / hear-0.1.22.tar.gz
| Download URL | hear-0.1.22.tar.gz |
|---|---|
| Size | 30.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d94436dafba61c3ce2a807e869fd60611af40e98896ee5fbe2acd411d5d20993
|
|
BLAKE2b-256 checksum How to use checksums |
92de2b9dfdc7627fc2500d3b68b5bcd5cedb8a8e0f86802cc144f04a4d6ff825
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / hear-0.1.22-py3-none-any.whl
| Download URL | hear-0.1.22-py3-none-any.whl |
|---|---|
| Size | 27.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
681eed9a6a278f4fe3df7443820c4937b2e0d44bfbc5939b5e8fd4701c69b902
|
|
BLAKE2b-256 checksum How to use checksums |
3a26a7401e92701f12a230999daa35c4c88464a0577085dc6f90c4e381dca4cd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for hear 0.1.22
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.