From ba2aa9fd6e71c361c252452ab8c48afbb695fd65 Mon Sep 17 00:00:00 2001 From: "Reece H. Dunn" Date: Mon, 19 Aug 2024 23:49:13 +0100 Subject: [PATCH] Remove the mel-scale spectrogram nodes now that filter banks are supported. --- README.md | 5 +---- __init__.py | 3 --- spect_nodes.py | 40 ---------------------------------------- 3 files changed, 1 insertion(+), 47 deletions(-) diff --git a/README.md b/README.md index 1d5c401..ab49d6d 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/__init__.py b/__init__.py index a6ec169..973be4f 100644 --- a/__init__.py +++ b/__init__.py @@ -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", } diff --git a/spect_nodes.py b/spect_nodes.py index d29bdc2..a8d2fb9 100644 --- a/spect_nodes.py +++ b/spect_nodes.py @@ -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}, )