This commit is contained in:
nmstoker 2020-07-11 17:48:05 +01:00
parent a18275daf5
commit 74f83b2d13
1 changed files with 5 additions and 4 deletions

View File

@ -87,6 +87,11 @@ class GANDataset(Dataset):
audio, mel = self.cache[idx]
else:
audio = self.ap.load_wav(wavpath)
if len(audio) < self.seq_len + self.pad_short:
audio = np.pad(audio, (0, self.seq_len + self.pad_short - len(audio)), \
mode='constant', constant_values=0.0)
mel = self.ap.melspectrogram(audio)
else:
@ -99,10 +104,6 @@ class GANDataset(Dataset):
audio = self.ap.load_wav(wavpath)
mel = np.load(feat_path)
if len(audio) < self.seq_len + self.pad_short:
audio = np.pad(audio, (0, self.seq_len + self.pad_short - len(audio)), \
mode='constant', constant_values=0.0)
# correct the audio length wrt padding applied in stft
audio = np.pad(audio, (0, self.hop_len), mode="edge")
audio = audio[:mel.shape[-1] * self.hop_len]