Just offer generic re-load for nv-tacotron

This commit is contained in:
James Betker 2021-08-12 09:09:12 -06:00
parent 154f5aa73c
commit 0c4d6b1916

View File

@ -98,8 +98,12 @@ class TextMelLoader(torch.utils.data.Dataset):
return text_norm
def __getitem__(self, index):
t, m, p = self.get_mel_text_pair(self.audiopaths_and_text[index])
if self.max_mel_len != None and m.shape[-1] > self.max_mel_len:
try:
t, m, p = self.get_mel_text_pair(self.audiopaths_and_text[index])
reload = False
except:
reload = True
if reload and self.max_mel_len != None and m.shape[-1] > self.max_mel_len:
# It's hard to handle this situation properly. Best bet is to return the a random valid token and skew the dataset somewhat as a result.
rv = random.randint(0,len(self))
return self[rv]