libritts - only write on successful check

This commit is contained in:
James Betker 2021-08-16 22:52:55 -06:00
parent 93e903af15
commit 7c086d0c2c

View File

@ -5,7 +5,7 @@ from tqdm import tqdm
if __name__ == '__main__':
libri_root = 'E:\\audio\\LibriTTS'
basis = 'train-other-500'
basis = 'train-clean-360'
readers = os.listdir(os.path.join(libri_root, basis))
ofile = open(os.path.join(libri_root, f'{basis}_list.txt'), 'w', encoding='utf-8')
@ -26,6 +26,7 @@ if __name__ == '__main__':
wav_file = '/'.join([basis, reader_dir, chapter_dir, f'{wav_file}.wav'])
if not os.path.exists(os.path.join(libri_root, wav_file)):
print(f'!WARNING could not open {wav_file}')
ofile.write(f'{wav_file}|{normalized_text}\n')
else:
ofile.write(f'{wav_file}|{normalized_text}\n')
ofile.flush()
ofile.close()