From 0c4d6b19160421ad33265955f7a2c366ecb780a5 Mon Sep 17 00:00:00 2001 From: James Betker Date: Thu, 12 Aug 2021 09:09:12 -0600 Subject: [PATCH] Just offer generic re-load for nv-tacotron --- codes/data/audio/nv_tacotron_dataset.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/codes/data/audio/nv_tacotron_dataset.py b/codes/data/audio/nv_tacotron_dataset.py index 76ce3848..44fe3c57 100644 --- a/codes/data/audio/nv_tacotron_dataset.py +++ b/codes/data/audio/nv_tacotron_dataset.py @@ -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]