Remove the mel-scale spectrogram nodes now that filter banks are supported.

This commit is contained in:
Reece H. Dunn
2024-08-20 12:09:29 +01:00
parent ee075b987d
commit ba2aa9fd6e
3 changed files with 1 additions and 47 deletions
+1 -4
View File
@@ -2,6 +2,7 @@
> A collection of nodes for working with audio data.
- [I/O](#io)
- [Filter Banks](#filter-banks)
- [Plotting](#plotting)
- [Spectrogram](#spectrogram)
- [License](#license)
@@ -38,16 +39,12 @@
| Spectrogram | Computes the spectrogram of a given `AUDIO` object. |
| Inverse Spectrogram | Converts a complex-valued spectrogram to `AUDIO`. |
| Griffin Lim | Converts a real-valued spectrogram to `AUDIO` using the Griffin-Lim algorithm. |
| Mel-scale Spectrogram | Computes the mel-scale spectrogram of a given `AUDIO` object. |
A spectrogram (`SPECT`) can be one of three types:
1. `complex` – a complex number valued spectrogram;
2. `magnitude` – a real valued spectrogram that is the absolute value of the `complex` spectrogram (power 1);
3. `power` – a real valued spectrogram that is the square of the `magnitude` spectrogram (power 2);
A mel-scale spectrogram (`MEL_SPECT`) is a `magnitude` or `power` spectrogram that has been converted
to the mel audio scale.
## License
Copyright (C) 2024 Reece H. Dunn
-3
View File
@@ -6,7 +6,6 @@ from .plot_nodes import (PlotWaveform, PlotSpectrogram, PlotFilterBank)
from .spect_nodes import (
Spectrogram, InverseSpectrogram,
GriffinLim,
MelSpectrogram
)
NODE_CLASS_MAPPINGS = {
@@ -23,7 +22,6 @@ NODE_CLASS_MAPPINGS = {
"ComfyAudio.Spectrogram": Spectrogram,
"ComfyAudio.InverseSpectrogram": InverseSpectrogram,
"ComfyAudio.GriffinLim": GriffinLim,
"ComfyAudio.MelSpectrogram": MelSpectrogram,
}
NODE_DISPLAY_NAME_MAPPINGS = {
@@ -40,5 +38,4 @@ NODE_DISPLAY_NAME_MAPPINGS = {
"ComfyAudio.Spectrogram": "Spectrogram",
"ComfyAudio.InverseSpectrogram": "Inverse Spectrogram",
"ComfyAudio.GriffinLim": "Griffin Lim",
"ComfyAudio.MelSpectrogram": "Mel-scale Spectrogram",
}
-40
View File
@@ -94,43 +94,3 @@ class GriffinLim:
waveform = waveform.unsqueeze(0) # 1 channel (mono) audio
return ({"waveform": waveform.unsqueeze(0),
"sample_rate": spectrogram["sample_rate"]}, )
class MelSpectrogram:
@classmethod
def INPUT_TYPES(s):
return {"required": {"audio": ("AUDIO",)},
"optional": {"stype": (("magnitude", "power"), {"default": "power"}),
"n_fft": ("INT", {"default": 400, "min": 1, "max": 2**32}),
"n_mels": ("INT", {"default": 128, "min": 1, "max": 2**32}),
"win_length": ("INT", {"default": -1, "min": -1, "max": 2**32}),
"hop_length": ("INT", {"default": -1, "min": -1, "max": 2**32})}}
CATEGORY = "AudioProcessing/spectrogram"
RETURN_TYPES = ("MEL_SPECT", )
FUNCTION = "spectrogram"
def spectrogram(self,
audio,
stype="power",
n_fft=400,
n_mels=128,
win_length=-1,
hop_length=-1):
if win_length == -1: win_length = None
if hop_length == -1: hop_length = None
waveform = audio["waveform"].movedim(0, -1).squeeze()
spectrogram = T.MelSpectrogram(sample_rate=audio["sample_rate"],
n_fft=n_fft,
n_mels=n_mels,
win_length=win_length,
hop_length=hop_length,
power=SPECTROGRAM_TYPE_TO_POWER[stype])(waveform)
return ({"spectrogram": spectrogram,
"sample_rate": audio["sample_rate"],
"stype": stype,
"n_fft": n_fft,
"n_mels": n_mels,
"win_length": win_length,
"hop_length": hop_length}, )