Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions hw4_nv/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ class MelSpectrogram(nn.Module):
super(MelSpectrogram, self).__init__()

self.config = config

self.mel_spectrogram = torchaudio.transforms.MelSpectrogram(
sample_rate=config.sr,
win_length=config.win_length,
hop_length=config.hop_length,
n_fft=config.n_fft,
f_min=config.f_min,
f_max=config.f_max,
n_mels=config.n_mels
n_mels=config.n_mels,
center=False,
)

# The is no way to set power in constructor in 0.5.0 version.
Expand All @@ -72,7 +72,8 @@ class MelSpectrogram(nn.Module):
:param audio: Expected shape is [B, T]
:return: Shape is [B, n_mels, T']
"""

audio = torch.nn.functional.pad(audio.unsqueeze(1), (int((self.config.n_fft-self.config.hop_length)/2), int((self.config.n_fft-self.config.hop_length)/2)), mode='reflect')
audio = audio.squeeze(1)
mel = self.mel_spectrogram(audio) \
.clamp_(min=1e-5) \
.log_()
Expand Down