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.1-py3-none-manylinux_2_17_x86_64.whl (482.7 kB view details)

Uploaded Python 3manylinux: glibc 2.17+ x86-64

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

Uploaded Python 3manylinux: glibc 2.17+ ARM64

libsonare-1.0.1-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.1-py3-none-manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for libsonare-1.0.1-py3-none-manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 d4031a6c24c509aa8b80c2e68a31a01a13d19acec1f032e871e2d9f7c10690d5
MD5 5f9f92641390b382702170118f782d93
BLAKE2b-256 e33dfc4f84942e77383cf242a6fb6d4b34d55f450efff3e692d27f2fdfc6f28c

See more details on using hashes here.

Provenance

The following attestation bundles were made for libsonare-1.0.1-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.1-py3-none-manylinux_2_17_aarch64.whl.

File metadata

File hashes

Hashes for libsonare-1.0.1-py3-none-manylinux_2_17_aarch64.whl
Algorithm Hash digest
SHA256 d37bcce7d173be55894553659965f741f6c8cbabb31a1fd6845b4587ea0ce5ce
MD5 b5ea165cd62b16b285057383942cc611
BLAKE2b-256 03ab552a2ea1bcfc1d839924f2013e163c8c7b4a05aca5f11855197bc3de6300

See more details on using hashes here.

Provenance

The following attestation bundles were made for libsonare-1.0.1-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.1-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for libsonare-1.0.1-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3fbb3cda8540255b7f5201b8f9503d0ea0df9514ab1f9493011fc34faca9f883
MD5 2e5c0bf47194635bdf339e152732ba6d
BLAKE2b-256 d0b53d5b4ca2423afb3af03df26041188237f9284d6d245f3595298354de68fc

See more details on using hashes here.

Provenance

The following attestation bundles were made for libsonare-1.0.1-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