| 145 | |
| 146 | |
| 147 | def prepare_input_sequence(texts, cpu_run=False): |
| 148 | |
| 149 | d = [] |
| 150 | for i,text in enumerate(texts): |
| 151 | d.append(torch.IntTensor( |
| 152 | text_to_sequence(text, ['english_cleaners'])[:])) |
| 153 | |
| 154 | text_padded, input_lengths = pad_sequences(d) |
| 155 | if not cpu_run: |
| 156 | text_padded = text_padded.cuda().long() |
| 157 | input_lengths = input_lengths.cuda().long() |
| 158 | else: |
| 159 | text_padded = text_padded.long() |
| 160 | input_lengths = input_lengths.long() |
| 161 | |
| 162 | return text_padded, input_lengths |
| 163 | |
| 164 | |
| 165 | class MeasureTime(): |