Skip to main content

Fast library to load MP3 into NumPY arrays

Project description

NP3

A fast python library to load mp3 data into NumPy arrays.

It is based on lieff's minimp3

Installation

pip install np3

Usage

import np3

mp3 = np3.MP3(path="/my/mp3/file")

# or

with open("/path/to/file.mp3") as mp3_fh:
    mp3 = np3.MP3(file=mp3_fh)

# or

data: bytes = obtain_mp3_data()
mp3 = np3.MP3(data=data)

print(f"Channels: {mp3.channels}")
print(f"Sampling rate: {mp3.hz} Hz")

length = len(mp3.samples[0]) / mp3.hz
print(f"Length: {length:.1f} seconds")

Threaded performance

GIL is released before decoding starts. On multi core machines this brings additional performance when decoding in separate threads. While decoding a single file does not parallelise, other python threads can continue working while the file is being processed. Where multiple files need decoding this performance gain becomes particularly significant.

from concurrent.futures import ThreadPoolExecutor

files = ["/path/to/file1.mp3", "/path/to/file2.mp3", ...]

with ThreadPoolExecutor() as executor:
    mp3s = executor.map(
        lambda p: np3.MP3(path=p),
        files,
    )

Project details


Download files

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

Source Distribution

np3-0.2.tar.gz (34.9 kB view details)

Uploaded Source

Built Distributions

np3-0.2-cp311-cp311-musllinux_1_1_x86_64.whl (111.4 kB view details)

Uploaded CPython 3.11 musllinux: musl 1.1+ x86-64

np3-0.2-cp311-cp311-musllinux_1_1_i686.whl (97.8 kB view details)

Uploaded CPython 3.11 musllinux: musl 1.1+ i686

np3-0.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (108.8 kB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

np3-0.2-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (137.5 kB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

np3-0.2-cp310-cp310-musllinux_1_1_i686.whl (96.9 kB view details)

Uploaded CPython 3.10 musllinux: musl 1.1+ i686

np3-0.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (86.6 kB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

np3-0.2-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl (136.7 kB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

File details

Details for the file np3-0.2.tar.gz.

File metadata

  • Download URL: np3-0.2.tar.gz
  • Upload date:
  • Size: 34.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.4

File hashes

Hashes for np3-0.2.tar.gz
Algorithm Hash digest
SHA256 d4e584034ad3cc61ea7990bab7b81e3cf7f2a40a13cd7401970d6c25cd90d35f
MD5 f4a6b70effcf54698d8095d0d4b402ce
BLAKE2b-256 44b163de6d36ca15cbaa58940cc21e0dde6b461a3fc36465ca673ed40d7b0162

See more details on using hashes here.

File details

Details for the file np3-0.2-cp311-cp311-musllinux_1_1_x86_64.whl.

File metadata

File hashes

Hashes for np3-0.2-cp311-cp311-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 da6f6dd8363e02e11891be08c25b4e0fd3f2f771fe4b4fd79d72178a5367a1ea
MD5 e4c29ac127e1f162817e1ab21ad66b7d
BLAKE2b-256 311706dc5895c4557ad4a9143a25a50a22135b21d713e251ea15b0727029c6e8

See more details on using hashes here.

File details

Details for the file np3-0.2-cp311-cp311-musllinux_1_1_i686.whl.

File metadata

  • Download URL: np3-0.2-cp311-cp311-musllinux_1_1_i686.whl
  • Upload date:
  • Size: 97.8 kB
  • Tags: CPython 3.11, musllinux: musl 1.1+ i686
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.4

File hashes

Hashes for np3-0.2-cp311-cp311-musllinux_1_1_i686.whl
Algorithm Hash digest
SHA256 43d4a615755c406ddbc2922d4eada66118cc8ea2adb1a93791d1cf2bc5ac7fc7
MD5 71ac8b0e1e1fead7e418284c09a25073
BLAKE2b-256 121afba2c5b5c7d10d28c7197db314b91b00a45f477f825bd83dd6423cc7a4f2

See more details on using hashes here.

File details

Details for the file np3-0.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for np3-0.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 263f7c83d565dfa00bbd8d6df6d70106b5ffe43cf735298097e71aa3e940584f
MD5 ba9b04ac3396ffa9fa3498217e81040c
BLAKE2b-256 59c5ac05c8482d93dec9b95d86e9ed4291314305794bc033ebe0e804cd38958b

See more details on using hashes here.

File details

Details for the file np3-0.2-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for np3-0.2-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 7c7b5e0439bdd2cc4011e21b67c981eb76b77e4e79cc385741a16fc3ca03546c
MD5 313cec4e1bc6fd76cd7cd14eca121f2e
BLAKE2b-256 9afaee88e86cc0c11cc28e8ef2d82a7f8ef1f94f79f0e2976678e3b0523c2a84

See more details on using hashes here.

File details

Details for the file np3-0.2-cp310-cp310-musllinux_1_1_i686.whl.

File metadata

  • Download URL: np3-0.2-cp310-cp310-musllinux_1_1_i686.whl
  • Upload date:
  • Size: 96.9 kB
  • Tags: CPython 3.10, musllinux: musl 1.1+ i686
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.4

File hashes

Hashes for np3-0.2-cp310-cp310-musllinux_1_1_i686.whl
Algorithm Hash digest
SHA256 c0fe6e5478730c5709f54f5c08a3b5c4e54f895285d1312708e3eaf5abbc2873
MD5 5d63ef72c3b1126474d05be3e9ab38da
BLAKE2b-256 92e78797d39ac936f9544d11121e9ad2ba75736a070dd1ede819b051d0aad365

See more details on using hashes here.

File details

Details for the file np3-0.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for np3-0.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b32e43e17e909b1d835175e876acad75e98d167494039e86d9d7e360ef32bfef
MD5 3cbba9a85b337a20c1698aa9ab99ce07
BLAKE2b-256 036def2e23ec5f6bb8bb4074f3f8208777d9ea090c7bb792fc81f17e9fad35b8

See more details on using hashes here.

File details

Details for the file np3-0.2-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for np3-0.2-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 7e20d3954c685da78cd69b07605f692a81f4ee26b586bc735dc125dbb70b22a1
MD5 7a3a851b32318de7850aa1396f7eeec8
BLAKE2b-256 e708870f4c41bc06c64e75b1640e5115a0f7d7aa1a603801b43ced5c4b8cf667

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page