From 1c6d16cffcd98199fdbc36edfddf153e40bfaf49 Mon Sep 17 00:00:00 2001 From: Edresson Casanova Date: Mon, 28 Feb 2022 15:29:22 -0300 Subject: [PATCH] Add a generic emotion dataset formatter --- TTS/tts/datasets/formatters.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/TTS/tts/datasets/formatters.py b/TTS/tts/datasets/formatters.py index ac3080c3..bc8a467c 100644 --- a/TTS/tts/datasets/formatters.py +++ b/TTS/tts/datasets/formatters.py @@ -419,6 +419,26 @@ def _voxcel_x(root_path, meta_file, voxcel_idx): return [x.strip().split("|") for x in f.readlines()] +def emotion(root_path, meta_file, ignored_speakers=None): + """Generic emotion dataset""" + txt_file = os.path.join(root_path, meta_file) + items = [] + with open(txt_file, "r", encoding="utf-8") as ttf: + for line in ttf: + if line.startswith("file_path"): + continue + cols = line.split(",") + wav_file = os.path.join(root_path, cols[0]) + speaker_id = cols[1] + emotion_id = cols[2].replace("\n", "") + # ignore speakers + if isinstance(ignored_speakers, list): + if speaker_id in ignored_speakers: + continue + items.append([wav_file, speaker_id, emotion_id]) + return items + + def baker(root_path: str, meta_file: str, **kwargs) -> List[List[str]]: # pylint: disable=unused-argument """Normalizes the Baker meta data file to TTS format