Skip to content

Commit 680ccfc

Browse files
committed
Tacotron2 --cpu-run fix
1 parent 3927e13 commit 680ccfc

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

PyTorch/SpeechSynthesis/Tacotron2/inference.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,15 +148,15 @@ def pad_sequences(batch):
148148
return text_padded, input_lengths
149149

150150

151-
def prepare_input_sequence(texts):
151+
def prepare_input_sequence(texts, cpu_run=False):
152152

153153
d = []
154154
for i,text in enumerate(texts):
155155
d.append(torch.IntTensor(
156156
text_to_sequence(text, ['english_cleaners'])[:]))
157157

158158
text_padded, input_lengths = pad_sequences(d)
159-
if torch.cuda.is_available():
159+
if torch.cuda.is_available() and not cpu_run:
160160
text_padded = torch.autograd.Variable(text_padded).cuda().long()
161161
input_lengths = torch.autograd.Variable(input_lengths).cuda().long()
162162
else:
@@ -236,7 +236,7 @@ def main():
236236

237237
measurements = {}
238238

239-
sequences_padded, input_lengths = prepare_input_sequence(texts)
239+
sequences_padded, input_lengths = prepare_input_sequence(texts, args.cpu_run)
240240

241241
with torch.no_grad(), MeasureTime(measurements, "tacotron2_time", args.cpu_run):
242242
mel, mel_lengths, alignments = jitted_tacotron2(sequences_padded, input_lengths)

PyTorch/SpeechSynthesis/Tacotron2/test_infer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ def main():
193193
measurements = {}
194194

195195
with MeasureTime(measurements, "pre_processing", args.cpu_run):
196-
sequences_padded, input_lengths = prepare_input_sequence(texts)
196+
sequences_padded, input_lengths = prepare_input_sequence(texts, args.cpu_run)
197197

198198
with torch.no_grad():
199199
with MeasureTime(measurements, "latency", args.cpu_run):

0 commit comments

Comments
 (0)