From 0a37404582707e166e5b97c4bdd325b173c32162 Mon Sep 17 00:00:00 2001 From: Thorsten Mueller Date: Tue, 21 Jan 2020 18:10:19 +0100 Subject: [PATCH] Added check for wav file existence --- datasets/createljspeech.py | 10 +++++++--- datasets/mrs.py | 9 ++++++--- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/datasets/createljspeech.py b/datasets/createljspeech.py index 0a5f983..7bf2e89 100644 --- a/datasets/createljspeech.py +++ b/datasets/createljspeech.py @@ -31,10 +31,14 @@ def main(): metadata = open(os.path.join(dir_base_ljspeech,"metadata.csv"),mode="w", encoding="utf8") for row in c.execute('SELECT audio_id, prompt, lower(prompt) FROM audiomodel ORDER BY length(prompt)'): - metadata.write(row[0] + "|" + row[1] + "|" + row[2] + "\n") audio_file_source = os.path.join(dir_base_mrs,"backend","audio_files", uid, row[0] + ".wav") - audio_file_dest = os.path.join(dir_base_ljspeech_wav,row[0] + ".wav") - copyfile(audio_file_source,audio_file_dest) + if os.path.isfile(audio_file_source): + metadata.write(row[0] + "|" + row[1] + "|" + row[2] + "\n") + audio_file_dest = os.path.join(dir_base_ljspeech_wav,row[0] + ".wav") + copyfile(audio_file_source,audio_file_dest) + else: + print("File " + audio_file_source + " no found. Skipping.") + metadata.close() conn.close() diff --git a/datasets/mrs.py b/datasets/mrs.py index bfdbb63..9ca8f07 100644 --- a/datasets/mrs.py +++ b/datasets/mrs.py @@ -44,9 +44,12 @@ def build_from_path(in_dir, out_dir, num_workers=1, tqdm=lambda x: x): for row in c.execute('SELECT audio_id, lower(prompt) FROM audiomodel ORDER BY length(prompt)'): wav_path = os.path.join(wav_dir, '%s.wav' % row[0]) - text = row[1] - futures.append(executor.submit(partial(_process_utterance, out_dir, index, wav_path, text))) - index += 1 + if os.path.isfile(wav_path): + text = row[1] + futures.append(executor.submit(partial(_process_utterance, out_dir, index, wav_path, text))) + index += 1 + else: + print("File " + wav_path + " no found. Skipping.") return [future.result() for future in tqdm(futures)]