Griffin Lim
The phase-guesser that turns spectrogram art back into sound
- spectrogram
- AUDIO
This is the node that makes the whole "generate a spectrogram, then play it" trick work - the Riffusion pattern, where a diffusion model paints a spectrogram and you need to hear what it painted. A magnitude or power spectrogram has no phase information, and without phase there's no exact audio. Griffin Lim is the algorithm that guesses phase anyway, well enough that you get recognizable sound out the other end.
How it works
The Griffin-Lim algorithm is iterative, and this node wraps torchaudio's implementation. It starts with a random phase guess, runs an inverse STFT, re-runs a forward STFT on the result, forces the magnitudes to match your target spectrogram, and repeats. Each iteration pulls the result closer to a signal that could have produced your spectrogram - while also having a consistent phase. The two inputs are the knobs on that loop:
n_iter(default 32) - how many iterations of the guess-and-correct loop. Fewer is faster and rougher; more is cleaner but slow. If your output sounds warbly or "phasey", this is the first number to raise.momentum(default 0.99) - how much each iteration carries over from the previous one. Higher momentum smooths convergence; leave it near the default unless you're chasing artifacts.
The input is a SPECT from Spectrogram (the FFT settings ride along in the metadata, so you never re-enter n_fft), and the output is a standard AUDIO object you can drop into PreviewAudio or SaveAudio.
The real-world catch
Griffin-Lim is a lossy reconstruction. It's a good guess, not the original - if your spectrogram was computed from real audio and then inverted, it will sound recognizably like that audio but with a characteristic smeary, slightly metallic sheen. The more you've edited the spectrogram (filtered it, denoised it, generated it from scratch), the more you're asking the algorithm to invent plausible audio from a picture, and the more it can sound like a ghost of the source.
Also note the mirror-image rule from Inverse Spectrogram: this node refuses complex spectrograms (it throws, because phase is already there - no guessing needed). If you have a complex spectrogram, Inverse Spectrogram gives you an exact reconstruction for free. Griffin-Lim is the fallback for when you only kept magnitude or power.
The other knob nobody mentions: n_iter has diminishing returns. 32 is a sane default; going to 200 will sound marginally better for a 6x runtime hit. If you're iterating on a workflow, lock n_iter low while you work and raise it for the final render.
Installing
ComfyUI Manager, search "comfyui-audio-processing", or the usual:
cd ComfyUI/custom_nodes
git clone https://github.com/rhdunn/comfyui-audio-processing
Restart, and that's it - no extra pip installs, no model files, because torchaudio is already in ComfyUI. This is one of the few places where a "novelty" audio feature (spectrogram → music) is genuinely practical in a ComfyUI graph, and this is the cheapest on-ramp to it.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| spectrogram | SPECT | — | |
| n_iteropt | INT | 321–4294967296 | — |
| momentumopt | FLOAT | 0.990–1 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| AUDIO | AUDIO | — |