Nodes/ComfyUI ARG Toolkit/Audio to Spectrogram
ComfyUI Node

Audio to Spectrogram

Spectrograms in ComfyUI

By AzelusLightvale·Created 12 months ago·Updated 2 days ago· 1
Audio to Spectrogram
  • audio
  • spectrogram
window_size25
hop_size15
windowing_shapeHanning
scaling_methodLogarithmic
db_norm80.00
cutoff_switchtrue
colormap_low#000000
colormap_mid#B73779
colormap_high#FCFDBF
active_db60.00

A spectrogram is a picture of sound: time runs left to right, frequency runs bottom to top, and brightness is loudness. It's also the classic ARG read tool, because a message hidden inside audio - the kind baked in as a visible text pattern, not just whispered over the track - shows up in that picture as clearly as a sign. SpectrogramEncoder ("Audio to Spectrogram") takes a ComfyUI audio clip and hands you back a rendered IMAGE you can preview or save. If you're solving an ARG, this is the node you want.

It comes from ComfyUI ARG Toolkit by AzelusLightvale, a GPLv3 hobby pack for cryptography, steganography, and secret-message work. The overlap between images and sound isn't new - Riffusion famously generated music as spectrogram images, proving the two domains share a canvas. This node goes the other way and turns the sound into the picture.

How it works

No exotic dependencies here - it's hand-rolled numpy DSP. It reads the standard ComfyUI AUDIO object (a waveform tensor plus sample_rate), takes the first channel, and slices the signal into overlapping frames. Each frame gets multiplied by a windowing function, zero-padded up to a power of two for FFT speed, then run through a real FFT and the magnitude is kept. Scaling turns that magnitude into what you actually see, a floor clamps the noise, and a custom colormap paints it as an image.

Inputs that matter

Most of the defaults are genuinely fine, so don't go touching everything.

  • audio (AUDIO) - wire in from ComfyUI's core Load Audio node.
  • window_size / hop_size - both in milliseconds, not samples. Defaults of 25 ms and 15 ms are the classic speech-analysis settings. Smaller window = better time resolution but worse frequency resolution; it's a trade-off.
  • scaling_method - Linear is raw amplitude, Quadratic is power, Logarithmic (default) is decibels, which is what makes quiet stuff visible.
  • db_norm (default 80) - the silence floor: anything more than 80 dB below the peak gets clamped to black. Raising it blacks out more background.
  • cutoff_switch / active_db - trims the empty vertical space so you don't render a tall strip of nothing.
  • colormap_low / colormap_mid / colormap_high - three hex colors the intensity is interpolated through. The defaults give that classic black → magenta → pale-yellow spectrogram look.

Gotchas I found reading the source

Two things will trip you up, and neither is in the README.

  • It only uses the first channel. The code reads audio[0, 0, :] - first clip, first channel, mono only. If your hidden message lives in the right channel, this node will happily render a spectrogram of silence.
  • "Logarithmic Mel" isn't real yet. The source computes mel bins and then immediately overwrites the result with a plain logarithmic pass - dead code. It behaves exactly like Logarithmic right now. If you genuinely need a mel spectrogram, do it outside this node.

What comes out and where it goes

One output, spectrogram (IMAGE), ready for any image node. Feed it to Save Image to keep it, or Preview Image to eyeball it while you hunt for that hidden text.

Installing it

Easiest via ComfyUI Manager - search "ComfyUI ARG Toolkit". Manually:

cd ComfyUI/custom_nodes
git clone https://github.com/AzelusLightvale/ComfyUI-ARG-Toolkit

Restart ComfyUI after. The pack depends on numpy, pillow, cryptography, stegano, and a few others; its autogenerated requirements.txt pins exact versions of torch, numpy, and opencv-python, so if pip starts meddling with your existing torch install, that file is the usual culprit.

Troubleshooting

  • No AUDIO socket anywhere - you need an audio source first. ComfyUI's core Load Audio node outputs the right type.
  • Spectrogram looks like black static - the clip may be near-silent, or db_norm is set so high everything is below the floor. Lower db_norm, or check you loaded the right clip.
  • A flat, dark image from speech-heavy audio - drop to Logarithmic scaling if it isn't already; linear scaling crushes quiet passages into black.
CategoryARG Toolkit/Steganography/Analysis

Inputs (11)

NameTypeDefaultDescription
audioAUDIOThe audio file to generate the spectrogram from
window_sizeINT25The size of each 'frame' in miliseconds.
hop_sizeINT15The size of the overlap between each 'frames' in miliseconds
windowing_shapeCOMBOHanningThe windowing function to use. Unless you know what you're doing, leave this as default.
scaling_methodCOMBOLogarithmicThe scaling method used for the spectrogram.
db_normFLOAT80.000–255The silence floor to the given volume (in negative) below peak volume.
cutoff_switchBOOLEANtrueEnable/Disable the trimming of empty vertical space in the spectrogram. This is mostly to save space when making spectrograms.
colormap_lowoptSTRING#000000The color of the lowest point of the spectrogram.
colormap_midoptSTRING#B73779The color of the middle point of the spectrogram.
colormap_highoptSTRING#FCFDBFThe color of the highest point of the spectrogram.
active_dboptFLOAT60.000–255If `cutoff_switch` is set to True, this will define the active dB range from 0 to not cut off.

Outputs (1)

NameTypeDescription
spectrogramIMAGE