Skip to main content

streaming mp3 decoder

Project description

# streamp3

This library implements streaming MP3 decompression using the LAME library.

## Status

## Installation

### Pip
pip install streamp3

## Usage
To begin decoding an MP3, construct an MP3Decoder, passing it in a binary
stream or `bytes` object. You can then access the `bit_rate`, `sample_rate`,
and `num_channels` properties for information about the MP3.

from streamp3 import MP3Decoder

with open('my.mp3', 'rb') as mp3_file:
decoder = MP3Decoder(mp3_file)
print(decoder.bit_rate, decoder.sample_rate, decoder.num_channels)

You can then read samples from the stream directly using the `read()` method
or use the decoder as an iterator. Samples are returned as `bytes` objects,
which are 16-bit PCM encoded, with samples interleaved across channels. This
example streams an MP3 file to the system speaker using

import pyaudio
from streamp3 import MP3Decoder

with open('my.mp3', 'rb') as mp3_file:
decoder = MP3Decoder(mp3_file)

audio = pyaudio.PyAudio()
device = audio.get_default_output_device_info()
speaker =,

for chunk in decoder:

## Development

### Setup
We generally use pyenv to create virtual environments. The following script
creates a virtual environment for the project and installs dependencies.

pyenv install 3.6.4
pyenv virtualenv 3.6.4 streamp3
pip install -r requirements.txt

LAME must also be installed. This can be done on OSX via homebrew.

brew install lame

### Deployment
The project uses for installation and is deployed to
[PyPI]( The project can be built for installation with
the following command:

python clean --all; rm -r ./dist
python sdist bdist_wheel

The wheel and source distribution can then be uploaded to PyPI using twine.

twine upload --repository-url= dist/*

## License

Copyright 2018 Pylon, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
See the License for the specific language governing permissions and
limitations under the License.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for streamp3, version 0.1.4
Filename, size File type Python version Upload date Hashes
Filename, size streamp3-0.1.4-cp36-cp36m-macosx_10_13_x86_64.whl (18.3 kB) File type Wheel Python version cp36 Upload date Hashes View hashes
Filename, size streamp3-0.1.4.tar.gz (31.2 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page