ComfyUI Node

GriffinLim

Turn a spectrogram back into audio without a neural vocoder

By kale4eat·Created 2 years ago·Updated about a year ago· 23
GriffinLim
  • spec
  • audio
n_fft400
win_length-1
hop_length-1

This is the node that goes the other direction from everything else in the spec category: instead of turning audio into a spectrogram, it turns a spectrogram back into audio. No model, no weights, no download - Griffin-Lim is a classic signal-processing algorithm, decades older than any neural vocoder, and it's the cheapest way to get something audible out of a spectrogram you've been staring at or generating.

How it works

A spectrogram only keeps magnitude - how loud each frequency is at each moment - and throws away phase, which is half of what a waveform actually needs to be reconstructed. Griffin-Lim's trick is iterative: it guesses a starting phase, reconstructs a waveform, re-runs the transform on that waveform, compares, and refines the phase guess again, looping until the estimate converges to something "consistent" with the magnitude spectrogram you gave it. That's not the original phase - there's no way to recover the true one from magnitude alone - so what comes out is recognizable speech with a characteristic buzzy, slightly robotic quality. That's the honest tradeoff against a trained neural vocoder (HiFi-GAN and friends), which sounds far cleaner but needs a model you don't have here. Griffin-Lim's real value in a dataset-building toolkit is as a fast, dependency-free sanity check: does this spectrogram actually sound like what I expect, without spinning up a vocoder just to find out.

The inputs and outputs that matter

  • spec (required, SPEC) - the spectrogram to invert.
  • n_fft (required, default 400) - must match the FFT size used to produce the spectrogram in the first place, not an arbitrary choice. Mismatch here and you'll get garbage or a shape error, not a warning.
  • win_length and hop_length (optional, both default -1) - leave them at -1 and they fall back to the standard torchaudio defaults derived from n_fft (window length equal to n_fft, hop length half of that). Set them explicitly only if the spectrogram you're feeding in was generated with non-default values - and if so, they need to match exactly.
  • audio (output) - the reconstructed waveform.

The trap worth knowing: this pack's SPEC type is generic across the whole spec category. SDT_LFCC and SDT_MFCC also output type SPEC, even though cepstral coefficients aren't a magnitude spectrogram - they're a lossy, decorrelated feature representation, not something Griffin-Lim can meaningfully invert. ComfyUI's type system won't stop you wiring an MFCC output into this node; the DSP math will just not do anything sensible with it. Only feed this a genuine magnitude or mel spectrogram (SDT_MelSpectrogram is the obvious candidate in this pack).

How to install it

Via ComfyUI Manager: search ComfyUI-speech-dataset-toolkit, install, restart. Manually:

cd ComfyUI/custom_nodes
git clone https://github.com/kale4eat/ComfyUI-speech-dataset-toolkit
cd ComfyUI-speech-dataset-toolkit
pip install torchaudio --index-url https://download.pytorch.org/whl/cu121   # match your CUDA version
pip install -r requirements.txt

Restart ComfyUI. This node adds nothing extra on top of the pack's baseline torchaudio requirement - no model to download, which is part of the appeal.

Common issues & troubleshooting

The audio sounds buzzy or robotic. That's not broken - it's the algorithm doing what Griffin-Lim does. Phase reconstruction from magnitude alone is inherently approximate. If you need genuinely clean audio out of a spectrogram, you need a trained neural vocoder, which this pack doesn't include; Griffin-Lim is for a quick listen, not final output.

Reconstruction is total noise, not just buzzy. Almost always a parameter mismatch - n_fft (and win_length/hop_length if you set them) doesn't match what generated the spectrogram. Go back to whichever node produced spec and copy its FFT settings over exactly.

You fed it an MFCC or LFCC output and got nonsense. Expected, per the trap above - those aren't invertible magnitude spectrograms. Route SDT_MelSpectrogram's output here instead.

Shape or dimension error on run. Usually the same root cause as garbled audio: a mismatched n_fft relative to the spectrogram's actual frequency-bin count. Match the FFT size before touching anything else.

Categoryspeech-dataset-toolkit/spec

Inputs (4)

NameTypeDefaultDescription
specSPEC
n_fftINT4000–4294967296
win_lengthoptINT-1-1–4294967296
hop_lengthoptINT-1-1–4294967296

Outputs (1)

NameTypeDescription
audioAUDIO