From 843fa6f3fa2db11a39407246733385e468d07d9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eren=20G=C3=B6lge?= Date: Mon, 10 Oct 2022 12:13:32 +0200 Subject: [PATCH] Check num of columns in coqui format (#2066) * Check 4 colums in coqui format * Fix encoding * Fixup --- TTS/tts/datasets/formatters.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/TTS/tts/datasets/formatters.py b/TTS/tts/datasets/formatters.py index 8b3603f4..f15ef96e 100644 --- a/TTS/tts/datasets/formatters.py +++ b/TTS/tts/datasets/formatters.py @@ -15,6 +15,15 @@ from tqdm import tqdm def coqui(root_path, meta_file, ignored_speakers=None): """Interal dataset formatter.""" + filepath = os.path.join(root_path, meta_file) + # ensure there are 4 columns for every line + with open(filepath, "r", encoding="utf8") as f: + lines = f.readlines() + num_cols = len(lines[0].split("|")) # take the first row as reference + for idx, line in enumerate(lines[1:]): + if len(line.split("|")) != num_cols: + print(f" > Missing column in line {idx + 1} -> {line.strip()}") + # load metadata metadata = pd.read_csv(os.path.join(root_path, meta_file), sep="|") assert all(x in metadata.columns for x in ["audio_file", "text"]) speaker_name = None if "speaker_name" in metadata.columns else "coqui"