Spectrogram
The linear-frequency alternative to a mel spectrogram
- audio
- spec
Same STFT machinery as SDT_MelSpectrogram, minus the perceptual mel warp. If you don't specifically need the mel scale - that matters for TTS/vocoder training, where models are built around it - this gives you the more literal representation: raw linear-frequency magnitude over time, no filterbank projection in between.
How it works
It's a short-time Fourier transform: chop the waveform into overlapping windows, FFT each one, and keep the resulting linear-frequency magnitude bins directly rather than passing them through a mel filterbank. The output type is SPEC, the same generic type SDT_MelSpectrogram produces - both feed into SDT_PlotSpectrogram interchangeably.
The inputs and outputs that matter
audio- the clip to analyze, required.n_fft(default400) - FFT window size, matchingSDT_MelSpectrogram's default. Bigger trades time resolution for frequency resolution; the default is a well-worn value most people don't need to touch.win_lengthandhop_length(optional, both default-1) - leave at-1for torchaudio's standard derived defaults (window length equal ton_fft, hop half of that). Set explicitly only if you need a specific frame rate to match something else in your pipeline.spec(output,SPEC) - the computed linear spectrogram.
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
pip install -r requirements.txt
No extra dependencies - pure signal processing on top of torchaudio, nothing to download.
Common issues & troubleshooting
Not sure whether you want this or SDT_MelSpectrogram. If you're feeding a TTS or vocoder pipeline, use SDT_MelSpectrogram - that's the representation those models are actually trained on. Use this node for general-purpose spectral analysis or visualization where mel warping isn't the goal.
Comparing two SPEC outputs and the frame counts don't match. hop_length controls that - mismatched hop lengths between two spectrograms (or between this node and SDT_MelSpectrogram) give you differently-shaped arrays even off identical audio. Set it explicitly and match it across both if you need aligned shapes.
Left win_length/hop_length at -1 and it looks fine. That's expected - torchaudio's derived defaults are sane for typical speech audio. Only override them if you need to match a specific frame rate elsewhere in your pipeline.
Feeding this SPEC into something that expects a mel spectrogram and getting bad results. A linear spectrogram and a mel spectrogram are both the pack's generic SPEC type, so ComfyUI's type system won't stop you from wiring one where the other is expected - but they carry genuinely different data (raw linear-frequency bins here versus perceptually mel-warped bins from SDT_MelSpectrogram). If a downstream model or node was trained on or expects mel features specifically, swapping in this node's output instead will run without erroring but produce nonsense. Know which one a given downstream node actually wants before wiring it in.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| audio | AUDIO | — | |
| n_fft | INT | 4000–4294967296 | — |
| win_lengthopt | INT | -1-1–4294967296 | — |
| hop_lengthopt | INT | -1-1–4294967296 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| spec | SPEC | — |