Fix unpacking multi-channel waveforms.

This commit is contained in:
Reece H. Dunn
2024-07-26 23:26:32 +01:00
parent 01c0f4a472
commit 9cd0c997e0
2 changed files with 4 additions and 4 deletions
+1 -1
View File
@@ -28,7 +28,7 @@ class PlotWaveform:
FUNCTION = "plot"
def plot(self, audio, title="Waveform"):
waveform = audio["waveform"].movedim(1, -1).numpy()
waveform = audio["waveform"].movedim(0, -1).numpy()
num_channels, num_frames, _ = waveform.shape
time_axis = torch.arange(0, num_frames) / audio["sample_rate"]
figure, axes = plt.subplots(num_channels, 1)
+3 -3
View File
@@ -23,7 +23,7 @@ class Spectrogram:
hop_length=-1):
if win_length == -1: win_length = None
if hop_length == -1: hop_length = None
waveform = audio["waveform"].movedim(1, -1).squeeze()
waveform = audio["waveform"].movedim(0, -1).squeeze()
spectrogram = T.Spectrogram(n_fft=n_fft,
win_length=win_length,
hop_length=hop_length,
@@ -55,7 +55,7 @@ class PowerSpectrogram:
hop_length=-1):
if win_length == -1: win_length = None
if hop_length == -1: hop_length = None
waveform = audio["waveform"].movedim(1, -1).squeeze()
waveform = audio["waveform"].movedim(0, -1).squeeze()
spectrogram = T.Spectrogram(n_fft=n_fft,
win_length=win_length,
hop_length=hop_length,
@@ -89,7 +89,7 @@ class MelSpectrogram:
hop_length=-1):
if win_length == -1: win_length = None
if hop_length == -1: hop_length = None
waveform = audio["waveform"].movedim(1, -1).squeeze()
waveform = audio["waveform"].movedim(0, -1).squeeze()
spectrogram = T.MelSpectrogram(sample_rate=audio["sample_rate"],
n_fft=n_fft,
n_mels=n_mels,