sense-music

Turn any audio file into structured analysis and annotated visualizations. Detects BPM, musical key, song structure, genre, mood, and transcribes lyrics. Liner notes for an AI.

pip install sense-music

Quickstart

from sense_music import analyze result = analyze("song.mp3") print(result.bpm.tempo) # 120.0 print(result.key.key) # "A" print(result.key.mode) # "minor" print(result.genre) # "electronic" print(result.mood) # ["energetic", "bright"] print(result.summary) # Natural language description result.save("output/") # JSON, HTML, spectrogram, waveform

Analysis Result

The analyze() function returns a result object with all detected features.

FieldTypeDescription
file_infoFileInfoSource audio metadata
durationfloatLength in seconds
bpmBPMInfoTempo detection (tempo, confidence)
keyKeyInfoKey detection (key, mode, confidence)
sectionslist[Section]Structural segments (intro, verse, chorus, etc.)
lyricslist[LyricLine]Transcribed lyrics with timestamps
energy_curvelist[float]Per-second RMS energy (0.0-1.0)
genrestrClassified genre
moodlist[str]Mood tags
summarystrNatural language description
spectrogramImageAnnotated mel spectrogram
waveformImageAnnotated waveform

Capabilities

Structural Sections

for section in result.sections: print(f"{section.label}: {section.start}s - {section.end}s")

Lyrics

result = analyze("song.mp3", lyrics=True, whisper_model="base")

Visualizations

result.spectrogram # Annotated mel spectrogram result.waveform # Annotated waveform result.save("output/") # Save all outputs to directory

Export

result.to_json() # Structured JSON result.to_html() # Standalone HTML report result.render_page("analysis.html") # Save HTML to file

Configuration

ParameterDefaultDescription
sourcerequiredFile path or HTTP/HTTPS URL
lyricsTrueTranscribe lyrics with Whisper
whisper_model"base"Whisper model size
max_duration600Max audio length in seconds

Supported Formats

.mp3 .wav .flac .ogg .m4a .aac .wma .opus

Security

Dependencies

librosa matplotlib Pillow numpy openai-whisper

Part of the huje.tools Ecosystem

sense-music is part of huje.tools — open-source tools for the agentic age. Use it with any AI agent that needs to perceive and understand audio content.