Plot Filter Bank

This commit is contained in:
Reece H. Dunn
2024-08-20 12:08:06 +01:00
parent 9c06a9137e
commit b6c719e30d
3 changed files with 31 additions and 5 deletions
+5 -4
View File
@@ -24,10 +24,11 @@
## Plotting
| Name | Description |
|------------------|--------------------------------------------|
| Plot Waveform | Plots the waveform of an `AUDIO` object. |
| Plot Spectrogram | Plots the spectrogram of a `SPECT` object. |
| Name | Description |
|----------------------------|--------------------------------------------|
| Plot Waveform | Plots the waveform of an `AUDIO` object. |
| Plot Spectrogram | Plots the spectrogram of a `SPECT` object. |
| Plot Filter Bank | Plots the `FILTER_BANK` object. |
## Spectrogram
+3 -1
View File
@@ -2,7 +2,7 @@
from .fb_nodes import MelScaleFilterBank
from .io_nodes import LoadAudio
from .plot_nodes import (PlotWaveform, PlotSpectrogram)
from .plot_nodes import (PlotWaveform, PlotSpectrogram, PlotFilterBank)
from .spect_nodes import (
Spectrogram, InverseSpectrogram,
GriffinLim,
@@ -17,6 +17,7 @@ NODE_CLASS_MAPPINGS = {
# Plotting
"ComfyAudio.PlotWaveform": PlotWaveform,
"ComfyAudio.PlotSpectrogram": PlotSpectrogram,
"ComfyAudio.PlotFilterBank": PlotFilterBank,
# Spectrogram
"ComfyAudio.Spectrogram": Spectrogram,
"ComfyAudio.InverseSpectrogram": InverseSpectrogram,
@@ -32,6 +33,7 @@ NODE_DISPLAY_NAME_MAPPINGS = {
# Plotting
"ComfyAudio.PlotWaveform": "Plot Waveform",
"ComfyAudio.PlotSpectrogram": "Plot Spectrogram",
"ComfyAudio.PlotFilterBank": "Plot Filter Bank",
# Spectrogram
"ComfyAudio.Spectrogram": "Spectrogram",
"ComfyAudio.InverseSpectrogram": "Inverse Spectrogram",
+23
View File
@@ -87,3 +87,26 @@ class PlotSpectrogram:
figure.suptitle(title)
figure.tight_layout()
return (plot2image(), )
class PlotFilterBank:
@classmethod
def INPUT_TYPES(s):
return {"required": {"fbank": ("FILTER_BANK",)},
"optional": {"title": ("STRING", {"default": "Filter Bank"}),
"xlabel": ("STRING", {"default": "filter bin"}),
"ylabel": ("STRING", {"default": "frequency bin"}),}}
CATEGORY = "AudioProcessing/plot"
RETURN_TYPES = ("IMAGE", )
FUNCTION = "plot"
def plot(self, fbank, title="Filter Bank", xlabel="filter bin", ylabel="frequency bin"):
figure, axes = plt.subplots(1, 1)
axes.imshow(fbank['fbank'], origin="lower",aspect="auto", interpolation="nearest")
axes.set_ylabel(ylabel)
axes.set_xlabel(xlabel)
axes.set_title(title)
figure.tight_layout()
return (plot2image(), )