Esta página se muestra en inglés. Una traducción al español está en curso.
ConfigsJul 19, 2026·3 min de lectura

Librosa — Audio and Music Analysis Library for Python

A Python package for music and audio signal analysis providing tools for feature extraction, spectral analysis, beat tracking, and audio manipulation used in music information retrieval research.

Listo para agents

Instalación lista para agent

Este activo puede instalarse después de elegir el runtime, revisar el plan y ejecutar el comando correspondiente.

Native · 98/100Política: permitir
Superficie agent
Cualquier agent MCP/CLI
Tipo
Skill
Instalación
Single
Confianza
Confianza: Established
Entrada
Librosa Overview
Comando de instalación directa
npx -y tokrepo@latest install 454a78f8-832c-11f1-9bc6-00163e2b0d79 --target codex

Ejecutar después de confirmar el plan con dry-run.

Introduction

Librosa is the standard Python library for music and audio analysis. It provides the building blocks for music information retrieval (MIR) research and audio machine learning, from loading files and computing spectrograms to extracting high-level features like tempo, key, and beat positions.

What Librosa Does

  • Loads audio files in various formats and resamples to target sample rates
  • Computes spectral representations: STFT, mel spectrograms, constant-Q transform, chromagrams
  • Extracts audio features: MFCCs, spectral centroid, zero-crossing rate, tonnetz
  • Performs beat tracking, onset detection, and tempo estimation
  • Provides time-stretching, pitch-shifting, and harmonic-percussive source separation

Architecture Overview

Librosa is built on NumPy and SciPy, using array operations for efficient signal processing. Audio loading delegates to soundfile (libsndfile) with optional audioread fallback for MP3/AAC. The feature extraction pipeline follows a modular design where each function takes raw audio or spectrograms and returns NumPy arrays. Caching via joblib avoids redundant computation in interactive analysis. The library maintains a functional API style without stateful objects.

Self-Hosting & Configuration

  • Install via pip with optional dependencies for MP3 support (pip install librosa[ffmpeg])
  • No configuration files; all parameters are function arguments with sensible defaults
  • Default sample rate is 22050 Hz (sufficient for most MIR tasks); override with sr parameter
  • Use librosa.display with matplotlib for spectrogram visualization
  • Works in Jupyter notebooks for interactive exploration

Key Features

  • Comprehensive feature extraction covering spectral, rhythmic, and tonal descriptors
  • Time-frequency representations with customizable hop length and window functions
  • Beat-synchronous feature aggregation for music structure analysis
  • Harmonic-percussive separation for isolating tonal and rhythmic components
  • Extensive documentation with tutorial notebooks and API reference

Comparison with Similar Tools

  • torchaudio — GPU-accelerated, PyTorch integration; librosa is simpler for research and prototyping
  • Essentia — C++ based with more algorithms; librosa is pure Python and easier to modify
  • madmom — focused on beat/onset detection; librosa covers broader feature extraction
  • pyAudioAnalysis — higher-level classification focus; librosa provides lower-level building blocks

FAQ

Q: Is librosa suitable for real-time audio processing? A: No, it is designed for offline analysis. For real-time, use libraries like pyaudio or sounddevice.

Q: Can librosa handle very long audio files? A: Yes, use the offset and duration parameters in librosa.load() to process segments, or stream with soundfile.

Q: What audio formats does librosa support? A: WAV and FLAC natively via soundfile. MP3, AAC, and others with ffmpeg or audioread installed.

Q: How do I visualize spectrograms? A: Use librosa.display.specshow() which integrates with matplotlib for publication-quality plots.

Sources

Discusión

Inicia sesión para unirte a la discusión.
Aún no hay comentarios. Sé el primero en compartir tus ideas.

Activos relacionados