From 9b4aac94a824898bbec135b930f954914f3a19c1 Mon Sep 17 00:00:00 2001 From: mueller91 Date: Mon, 21 Sep 2020 12:13:02 +0200 Subject: [PATCH] fix: linter issues --- TTS/speaker_encoder/config.json | 16 ++++++++-------- TTS/speaker_encoder/dataset.py | 1 - TTS/tts/datasets/preprocess.py | 31 ++++++++++++++++--------------- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/TTS/speaker_encoder/config.json b/TTS/speaker_encoder/config.json index 332f58bb..4fbd84cc 100644 --- a/TTS/speaker_encoder/config.json +++ b/TTS/speaker_encoder/config.json @@ -59,43 +59,43 @@ [ { "name": "vctk_slim", - "path": "../../audio-datasets/en/VCTK-Corpus/", + "path": "../../../audio-datasets/en/VCTK-Corpus/", "meta_file_train": null, "meta_file_val": null }, { "name": "libri_tts", - "path": "../../audio-datasets/en/LibriTTS/train-clean-100", + "path": "../../../audio-datasets/en/LibriTTS/train-clean-100", "meta_file_train": null, "meta_file_val": null }, { "name": "libri_tts", - "path": "../../audio-datasets/en/LibriTTS/train-clean-360", + "path": "../../../audio-datasets/en/LibriTTS/train-clean-360", "meta_file_train": null, "meta_file_val": null }, { "name": "libri_tts", - "path": "../../audio-datasets/en/LibriTTS/train-other-500", + "path": "../../../audio-datasets/en/LibriTTS/train-other-500", "meta_file_train": null, "meta_file_val": null }, { "name": "voxceleb1", - "path": "../../audio-datasets/en/voxceleb1/", + "path": "../../../audio-datasets/en/voxceleb1/", "meta_file_train": null, "meta_file_val": null }, { "name": "voxceleb2", - "path": "../../audio-datasets/en/voxceleb2/", + "path": "../../../audio-datasets/en/voxceleb2/", "meta_file_train": null, "meta_file_val": null }, { - "name": "common_voice_wav", - "path": "../../audio-datasets/en/MozillaCommonVoice", + "name": "common_voice", + "path": "../../../audio-datasets/en/MozillaCommonVoice", "meta_file_train": "train.tsv", "meta_file_val": "test.tsv" } diff --git a/TTS/speaker_encoder/dataset.py b/TTS/speaker_encoder/dataset.py index 38757ce9..33cc4f36 100644 --- a/TTS/speaker_encoder/dataset.py +++ b/TTS/speaker_encoder/dataset.py @@ -64,7 +64,6 @@ class MyDataset(Dataset): def __parse_items(self): self.speaker_to_utters = {} for i in self.items: - text_ = i[0] path_ = i[1] speaker_ = i[2] if speaker_ in self.speaker_to_utters.keys(): diff --git a/TTS/tts/datasets/preprocess.py b/TTS/tts/datasets/preprocess.py index 73a56774..02954c04 100644 --- a/TTS/tts/datasets/preprocess.py +++ b/TTS/tts/datasets/preprocess.py @@ -160,7 +160,7 @@ def nancy(root_path, meta_file): return items -def common_voice_wav(root_path, meta_file): +def common_voice(root_path, meta_file): """Normalize the common voice meta data file to TTS format.""" txt_file = os.path.join(root_path, meta_file) items = [] @@ -258,16 +258,15 @@ def vctk(root_path, meta_files=None, wavs_path='wav48'): def vctk_slim(root_path, meta_files=None, wavs_path='wav48'): - test_speakers = meta_files """homepages.inf.ed.ac.uk/jyamagis/release/VCTK-Corpus.tar.gz""" items = [] - meta_files = glob(f"{os.path.join(root_path,'txt')}/**/*.txt", recursive=True) - for meta_file in meta_files: - _, speaker_id, txt_file = os.path.relpath(meta_file, + txt_files = glob(f"{os.path.join(root_path,'txt')}/**/*.txt", recursive=True) + for text_file in txt_files: + _, speaker_id, txt_file = os.path.relpath(text_file, root_path).split(os.sep) file_id = txt_file.split('.')[0] - if isinstance(test_speakers, list): # if is list ignore this speakers ids - if speaker_id in test_speakers: + if isinstance(meta_files, list): # if is list ignore this speakers ids + if speaker_id in meta_files: continue wav_file = os.path.join(root_path, wavs_path, speaker_id, file_id + '.wav') @@ -276,21 +275,21 @@ def vctk_slim(root_path, meta_files=None, wavs_path='wav48'): return items # ======================================== VOX CELEB =========================================== -def voxceleb2(root_path, meta_file): +def voxceleb2(root_path, meta_file=None): """ :param meta_file Used only for consistency with load_meta_data api """ - return _voxcel_x(root_path, voxcel_idx="2") + return _voxcel_x(root_path, meta_file, voxcel_idx="2") -def voxceleb1(root_path, meta_file): +def voxceleb1(root_path, meta_file=None): """ :param meta_file Used only for consistency with load_meta_data api """ - return _voxcel_x(root_path, voxcel_idx="1") + return _voxcel_x(root_path, meta_file, voxcel_idx="1") -def _voxcel_x(root_path, voxcel_idx): +def _voxcel_x(root_path, meta_file, voxcel_idx): assert voxcel_idx in ["1", "2"] expected_count = 148_000 if voxcel_idx == "1" else 1_000_000 voxceleb_path = Path(root_path) @@ -298,7 +297,11 @@ def _voxcel_x(root_path, voxcel_idx): cache_to.parent.mkdir(exist_ok=True) # if not exists meta file, crawl recursively for 'wav' files - if not cache_to.exists(): + if meta_file is not None: + with open(str(meta_file), 'r') as f: + return [x.strip().split('|') for x in f.readlines()] + + elif not cache_to.exists(): cnt = 0 meta_data = "" wav_files = voxceleb_path.rglob("**/*.wav") @@ -316,5 +319,3 @@ def _voxcel_x(root_path, voxcel_idx): with open(str(cache_to), 'r') as f: return [x.strip().split('|') for x in f.readlines()] - -