Skip to main content

streamp3

This library implements streaming MP3 decompression using the LAME library.

Status

PyPI CircleCI Coveralls

Installation

First, make sure you have the LAME libraries and headers installed.

macOS

brew install lame

Debian/Ubuntu

apt install libmp3lame-dev

Install with 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 PyAudio.

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 = audio.open(output=True,
                         input_device_index=device['index'],
                         format=pyaudio.paInt16,
                         channels=decoder.num_channels,
                         rate=decoder.sample_rate)

    for chunk in decoder:
        speaker.write(chunk)

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

Deployment

The project uses setup.py for installation and is deployed to PyPI. The project can be built for installation with the following command:

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

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

twine upload --repository-url=https://upload.pypi.org/legacy/ 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

  http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Metadata

Release files for streamp3 0.1.11

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

Source distribution (sdist)

Source distribution for streamp3 0.1.11
File Size Uploaded Provenance Actions
streamp3-0.1.11.tar.gz 10.9 kB Without provenance Details for streamp3-0.1.11.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for streamp3 0.1.11
File Interpreter ABI Platform Actions
streamp3-0.1.11-cp39-cp39-macosx_12_0_x86_64.whl CPython 3.9 CPython 3.9 macOS 12.0+ x86-64 Details for streamp3-0.1.11-cp39-cp39-macosx_12_0_x86_64.whl

Total release size: 33.6 kB

Release files / streamp3-0.1.11.tar.gz

Download URL streamp3-0.1.11.tar.gz
Size 10.9 kB
Tags Source
SHA-256 checksum
How to use checksums
8e1182b72f93cb3955cfbef56b823feea03b9be966cb94543b6c28c89893ac98
BLAKE2b-256 checksum
How to use checksums
c2cecc13bc4b4afed7a93494ba6b1e19f8b8b1288bce8317c0a024b33b9aee68
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.13

Release files / streamp3-0.1.11-cp39-cp39-macosx_12_0_x86_64.whl

Download URL streamp3-0.1.11-cp39-cp39-macosx_12_0_x86_64.whl
Size 22.6 kB
Tags CPython 3.9 macOS 12.0+ x86-64
SHA-256 checksum
How to use checksums
b5319e1d36ebba1a6cfdd6ab16376f3a2ee317f126a38ca04a8045868bc8ff7a
BLAKE2b-256 checksum
How to use checksums
51233c250cb47fe07405bcb5cad6358389b0e5253e92b18edc89cbfdff18b30c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.13

Security for streamp3 0.1.11

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.

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