Skip to main content

Fast audio analysis library — librosa-like API, tens of times faster (C++ with Python bindings)

Project description

libsonare

PyPI npm License

Fast audio analysis library for Python -- librosa-like API, tens of times faster.

Built on a C++ core with zero Python dependencies.

Installation

pip install libsonare

Supported platforms: Linux (x86_64, aarch64), macOS (Apple Silicon).

Quick Start

import libsonare

# From raw samples
bpm = libsonare.detect_bpm(samples, sample_rate=22050)
key = libsonare.detect_key(samples, sample_rate=22050)
print(f"{key.root.name} {key.mode.name}")  # e.g. "C MAJOR"

# Full analysis
result = libsonare.analyze(samples, sample_rate=22050)
print(f"BPM: {result.bpm}, Key: {result.key}")

# Audio class (load files directly)
audio = libsonare.Audio.from_file("song.mp3")
print(f"BPM: {audio.detect_bpm()}")
print(f"Key: {audio.detect_key()}")
print(f"Mel: {audio.mel_spectrogram().n_mels}x{audio.mel_spectrogram().n_frames}")

CLI

sonare analyze song.mp3
# > Estimated BPM : 161.00 BPM  (conf 75.0%)
# > Estimated Key : C major  (conf 100.0%)

sonare bpm song.mp3 --json       # {"bpm": 161.0}
sonare key song.mp3              # Key: C major (confidence: 100.0%)
sonare spectral song.mp3         # Spectral features table
sonare pitch song.mp3            # Pitch tracking (pYIN)
sonare mel song.mp3              # Mel spectrogram shape
sonare chroma song.mp3           # Chromagram with visualization

Features

  • Detection: BPM, key, beats, onsets
  • Analysis: Full music analysis (BPM + key + time signature + beats)
  • Effects: HPSS, pitch shift, time stretch, normalize, trim
  • Features: STFT, mel spectrogram, MFCC, chroma, spectral features, pitch tracking (YIN/pYIN)
  • Conversions: Hz/mel/MIDI/note, frames/time
  • I/O: Load WAV/MP3 files, resample

librosa Compatibility

Default parameters match librosa:

  • Sample rate: 22050 Hz
  • n_fft: 2048
  • hop_length: 512
  • n_mels: 128

Also available

npm install @libraz/libsonare  # JavaScript/TypeScript (WASM)

License

Apache-2.0

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

libsonare-1.0.2-py3-none-manylinux_2_17_x86_64.whl (482.7 kB view details)

Uploaded Python 3manylinux: glibc 2.17+ x86-64

libsonare-1.0.2-py3-none-manylinux_2_17_aarch64.whl (444.2 kB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARM64

libsonare-1.0.2-py3-none-macosx_11_0_arm64.whl (367.5 kB view details)

Uploaded Python 3macOS 11.0+ ARM64

File details

Details for the file libsonare-1.0.2-py3-none-manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for libsonare-1.0.2-py3-none-manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 1a4163c2741e6dea20f6b003866e523b9f2cc993d731d68fd5f95261da47d1c2
MD5 af13460735b950ad395b61ac45151e44
BLAKE2b-256 7dbbad419fef7d98852a61b0101382acef0aabdf6aa3bdd0d9c415f5ff29892d

See more details on using hashes here.

Provenance

The following attestation bundles were made for libsonare-1.0.2-py3-none-manylinux_2_17_x86_64.whl:

Publisher: publish.yml on libraz/libsonare

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file libsonare-1.0.2-py3-none-manylinux_2_17_aarch64.whl.

File metadata

File hashes

Hashes for libsonare-1.0.2-py3-none-manylinux_2_17_aarch64.whl
Algorithm Hash digest
SHA256 f1adcf72cca74e18efb1054b48aed543f41a3982d75b68dc8910f770e92601b8
MD5 306c23a029c10e5764b95dfcae95a36e
BLAKE2b-256 03ca941775173aa4709c23acd790777fb9a58ae72ec95e1426eda65160831361

See more details on using hashes here.

Provenance

The following attestation bundles were made for libsonare-1.0.2-py3-none-manylinux_2_17_aarch64.whl:

Publisher: publish.yml on libraz/libsonare

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file libsonare-1.0.2-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for libsonare-1.0.2-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0b74bae93b0616115cd110adfda5a3cb214ae47deb3eaf9797a635519cd34463
MD5 0874faeee4badc795ebbf0abf6438d19
BLAKE2b-256 67c5ec4ac0f3a5ca9b08201ab5f8432c84ca4e4f63d012b9524add3bafe5a590

See more details on using hashes here.

Provenance

The following attestation bundles were made for libsonare-1.0.2-py3-none-macosx_11_0_arm64.whl:

Publisher: publish.yml on libraz/libsonare

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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