Audio Resampler
Audio Resampler is a Python library designed for converting audio data between different formats and sample rates. It supports PCM and u-law audio formats and provides a flexible API for audio processing.
Features
- Convert audio data between PCM and u-law formats.
- Resample audio data to different sample rates.
- Support for various bit depths.
- Easy-to-use API with configuration options.
Installation
To install the library, use pip:
pip install audio-pcm-resampler
Usage
Basic Example
Convert PCM format to PCM
from audio_pcm_resampler.audio_resampler import AudioResampler, AudioResamplerConfig
from audio_pcm_resampler.audio_format import PCMFormat, ULAWFormat, BitDepth
from audio_pcm_resampler.data_type_conversion import bytes_2_numpy
# open input file
file = "I_want_to_create_the_world_int16_8khz.wav"
from audio_pcm_resampler.open_wav import open_wav_file
audio = open_wav_file(file)
# Initialize the resampler
resampler = AudioResampler(AudioResamplerConfig(
# Input format must match the one from the file
input_format=PCMFormat(
sample_rate=audio.params.framerate,
bit_depth=BitDepth.INT16,
),
output_format=PCMFormat(
sample_rate=24_000,
bit_depth=BitDepth.INT16,
)
))
# Process PCM input audio data, must use NDArray as input
input_data = bytes_2_numpy(audio.frames, resampler.config.input_format.bit_depth.to_numpy())
output_data = resampler.process(input_data)
Convert PCM to ULAW
from audio_pcm_resampler.audio_resampler import AudioResampler, AudioResamplerConfig
from audio_pcm_resampler.audio_format import PCMFormat, ULAWFormat, BitDepth
from audio_pcm_resampler.data_type_conversion import bytes_2_numpy
# open input file
file = "I_want_to_create_the_world_int16_8khz.wav"
from audio_pcm_resampler.open_wav import open_wav_file
audio = open_wav_file(file)
# Initialize the resampler
resampler = AudioResampler(AudioResamplerConfig(
# Input format must match the one from the file
input_format=PCMFormat(
sample_rate=audio.params.framerate,
bit_depth=BitDepth.INT16,
),
output_format=ULAWFormat()
))
# Process PCM input audio data, must use NDArray as input
input_data = bytes_2_numpy(audio.frames, resampler.config.input_format.bit_depth.to_numpy())
output_data = resampler.process(input_data)
Requirements
- Python >= 3.10
- NumPy
- Pydantic
- soxr
Contributing
Contributions are welcome! If you find a bug or have a feature request, please open an issue on the GitHub repository.
License
This project is licensed under the MIT License. See the LICENSE file for details.
Author
Metadata
Release files for audio-pcm-resampler 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| audio_pcm_resampler-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Release files / audio_pcm_resampler-0.1.0-py3-none-any.whl
| Download URL | audio_pcm_resampler-0.1.0-py3-none-any.whl |
|---|---|
| Size | 8.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e4965fdbd7dd1d9c02af501464d4fae7f62c323c8b2050a91448f088c9909ddd
|
|
BLAKE2b-256 checksum How to use checksums |
91953affae69f2d105162f584a1f14d66c428d356aefe7a7fc4ecc4edf8681d7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.1.2 CPython/3.9.14 Darwin/25.3.0
|
Security for audio-pcm-resampler 0.1.0
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.