Librosa Audio Analysis
Read Any Audio File Into Numbers Your Workflow Can React To
- energy_levels
- timestamps
- analysis_text
- analysis_type
Every audio-reactive workflow starts the same way: some piece of software has to turn a song into numbers a machine can react to. In the Kayarte pack, that piece is Librosa Audio Analysis ("LibrosaAnalysisNode"), the front door. Point it at an audio file on disk, pick an analysis style, and it hands you energy levels and timestamps that the rest of the pipeline chews on. It's the only node in the pack that touches the actual audio file - everything after it is pure math on its outputs.
What the analysis types actually do
The node is a thin wrapper around the librosa Python library, and the nine analysis_type options are nine different readings of the same file. Worth knowing, because they produce wildly different amounts of data:
- onset - detects note/beat starts, so you get a sparse, musical list of moments. Energy is the RMS loudness at each onset.
- beat - actual tempo-based beat tracking. Sparse and musical; great for percussive tracks.
- tempo - the onset-strength envelope as a continuous curve (the "how punchy is the music right now" signal).
- mel - the mean of a mel spectrogram across frequency, so it tracks how much spectral energy there is rather than plain loudness.
- spectral - the spectral centroid, a.k.a. brightness. Higher on bright, airy audio, lower on muffled stuff.
- segment - spectral onset detection that finds section boundaries (verse/chorus-ish changes).
- default / second / half_second - plain RMS energy at a fixed hop, sampled continuously (every frame, every second, every half second). Dense and simple.
Every method normalizes the energy to 0–1 at the end, so downstream nodes see consistent ranges. The author's example workflow uses spectral with a 128 window - that brightness-based signal tends to look more "alive" than raw loudness.
The inputs that matter
- audio_file - an absolute path to the file as plain text. The author's own example points it at an
.mp3, so compressed audio generally works - but if you hit a decode error, convert to WAV first; that's the reliable fix. - analysis_type - the nine above. As a beginner, start with
beatoronset: they give you the most musical, sparse signal, and (bigger reason, below) the least data. - window_size - 128–2048, default 512, step 128. The length of the frame used for RMS energy. Bigger = smoother, less precise; smaller = snappier, noisier.
Outputs
Four outputs, and you'll use all of them:
- energy_levels (
AUDIO_ENERGY) - the normalized loudness/spectral curve. Goes into Audio To Noise Parameters. - timestamps (
TIMESTAMPS) - the time in seconds of each measurement. Same destination. - analysis_text (
STRING) - a little text readout (duration, measurement count, window size). This is your debug friend; hook it to a text display. - analysis_type (
ANALYSIS_TYPE) - a pass-through of your choice, which the downstream nodes require even though they don't show it as a widget. Wire it along or the pack won't run.
Here's why the choice matters more than it looks: the number of measurements this node produces becomes the batch size of the latent sequence downstream - especially in Advanced Audio Noise Patterns, which makes one image per timestamp. The README's own numbers are sobering: a 89-second track under default gives roughly 122,000 measurements, while beat gives 14–168 and onset gives 60–500. Long track + default + the advanced node = instant OOM. Pick sparse analyses.
Installing
Via ComfyUI Manager (search "AudioDriven Latent Space Tools") or:
cd ComfyUI/custom_nodes
git clone https://github.com/Kayarte/AudioDriven-Latent-Space-Tools-for-ComfyUI
then restart ComfyUI. Now the part the README skips: this node imports librosa, but the pack ships no requirements.txt, and ComfyUI doesn't include librosa. You'll want:
pip install librosa
in your ComfyUI environment (it pulls numba, scipy, and soundfile along with it). Miss this and the whole pack fails to import with No module named 'librosa'.
Troubleshooting
The node fails soft: if anything throws - bad path, unreadable file, weird format - it returns [1.0] energy, [0.0] timestamp, and an Error: ... string in analysis_text rather than crashing. So when the pack seems to produce nothing, read analysis_text before blaming the sampler. Nine times out of ten it's the file path or a codec your librosa install can't decode; WAV conversion fixes both.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| audio_file | STRING | path/to/audio/file.wav | — |
| analysis_type | COMBO | default | 9 options: default, onset, segment, tempo, mel, spectral, +3 |
| window_size | INT | 512128–2048 | — |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| energy_levels | AUDIO_ENERGY | — |
| timestamps | TIMESTAMPS | — |
| analysis_text | STRING | — |
| analysis_type | ANALYSIS_TYPE | — |