MelSpectrogram
The standard input feature behind most modern TTS
- audio
- melspec
If you're building a dataset for training or fine-tuning a TTS model or a vocoder, this is likely the exact feature you need. A mel spectrogram - a spectrogram whose frequency axis is warped to match roughly how humans actually perceive pitch, spacing lower frequencies out more finely than high ones - is the near-universal intermediate representation between text and waveform in modern speech synthesis (Tacotron-style acoustic models, HiFi-GAN and friends as vocoders). This node computes it from a loaded clip.
How it works
It's a short-time Fourier transform followed by a mel filterbank: chop the waveform into overlapping windows, FFT each one to get frequency content, then project that onto a bank of mel-scaled triangular filters that compress the linear frequency axis into something closer to perceptual pitch spacing. The result is a 2D array - mel bins over time - rather than a waveform, which is why the output type here is SPEC, the same generic spectrogram type the pack's other spec-category nodes use.
The inputs and outputs that matter
audio- the clip to analyze, required.n_fft(default400) - FFT window size. Bigger gives you finer frequency resolution at the cost of coarser time resolution;400at typical speech sample rates is a well-worn default, not something most people need to touch.n_mels(default128) - how many mel filterbank bins to compute. This is the number that actually matters for downstream compatibility: if you're feeding this into a specific vocoder or acoustic model, it almost certainly expects a fixedn_mels(80 is another extremely common convention in TTS pipelines), so check what your target model was trained on before assuming the default is right.win_lengthandhop_length(optional, both default-1) - leave at-1for torchaudio's standard derived defaults (window length equal ton_fft, hop length half of that); set explicitly only if you need a specific frame rate to match another tool in your pipeline.melspec(output,SPEC) - the computed mel 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 beyond torchaudio - this is a pure signal-processing node, nothing to download.
Common issues & troubleshooting
Shape mismatch feeding this into a specific TTS/vocoder model. Almost always n_mels not matching what that model expects - 80 vs 128 is the classic mismatch. Check the target model's training config or documentation for its expected mel bin count before assuming this node's defaults line up.
Trying to get audio back out and it sounds buzzy. That's SDT_GriffinLim's job, and it's an inherent limitation of that algorithm, not this node - Griffin-Lim can only approximate the phase information a mel spectrogram never had, so reconstruction is never as clean as running it through a real trained vocoder.
Not sure whether you want this or SDT_MFCC/SDT_LFCC. If your downstream task is speech synthesis or a spectrogram-conditioned model, this is almost certainly the right node - mel spectrograms retain enough detail to be resynthesized (approximately). MFCC and LFCC compress much further into decorrelated cepstral coefficients, which are great for classification-style tasks (speaker ID, spoof detection) but not something you resynthesize audio from.
Different frame counts between two clips you're trying to compare or stack. That's expected if the clips have different lengths - this node computes one frame per hop, so total frame count scales with clip duration at your chosen hop_length. Pad or trim clips to matching lengths first if you need aligned shapes.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| audio | AUDIO | — | |
| n_fft | INT | 4000–4294967296 | — |
| n_mels | INT | 1280–4294967296 | — |
| win_lengthopt | INT | -1-1–4294967296 | — |
| hop_lengthopt | INT | -1-1–4294967296 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| melspec | SPEC | — |