Skip to content

Commit

Permalink
Check num of columns in coqui format (#2066)
Browse files Browse the repository at this point in the history
* Check 4 colums in coqui format

* Fix encoding

* Fixup
  • Loading branch information
erogol authored Oct 10, 2022
1 parent f3b947e commit 843fa6f
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions TTS/tts/datasets/formatters.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@

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"
Expand Down

0 comments on commit 843fa6f

Please sign in to comment.