From c123d499ba4b03e2c1ac3df2055e796eb80953e7 Mon Sep 17 00:00:00 2001 From: Brandon Thomas Date: Fri, 3 Sep 2021 02:41:42 -0400 Subject: [PATCH] fix newlines issue --- models/tts/vocodes_common.py | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/models/tts/vocodes_common.py b/models/tts/vocodes_common.py index 77ef1745b7..4b2160831b 100644 --- a/models/tts/vocodes_common.py +++ b/models/tts/vocodes_common.py @@ -82,23 +82,22 @@ def load_hifigan_model(checkpoint_path, super_resolution = False): def preprocess_text(text, raw_input=True): # TODO: Handle ARPAbet - sequence = None - for i in text.split("\n"): - if len(i) < 1: + pre_sequence = "" + for line in text.split("\n"): + if len(line) < 1: continue - print(i) if raw_input: - if i[-1] != ";": - i = i+";" + if line[-1] != ";": + line = line + ";" else: - #i = ARPA(i) + #line = ARPA(line) pass - print(i) - with torch.no_grad(): - # save VRAM by not including gradients - sequence = np.array(text_to_sequence(i, ['english_cleaners']))[None, :] - sequence = torch.autograd.Variable(torch.from_numpy(sequence)).cuda().long() - break # TODO: Handle multiple lines. + pre_sequence += line + + with torch.no_grad(): + # save VRAM by not including gradients + sequence = np.array(text_to_sequence(pre_sequence, ['english_cleaners']))[None, :] + sequence = torch.autograd.Variable(torch.from_numpy(sequence)).cuda().long() return sequence class NumpyEncoder(json.JSONEncoder): @@ -241,6 +240,8 @@ class TacotronWaveglowPipeline: assert('output_spectrogram_filename' in args) assert('output_metadata_filename' in args) + print('Raw text: {}'.format(args['raw_text'])) + sequence = preprocess_text(args['raw_text']) tacotron = self.tacotron_model_cache[args['synthesizer_checkpoint_path']]