common voice preprocessor and tests, small refactoring within tests

This commit is contained in:
Thomas Werkmeister
2019-04-25 11:35:18 +02:00
parent 8b1da591fc
commit d1a7ad545d
5 changed files with 84 additions and 11 deletions
+19 -2
View File
@@ -1,6 +1,7 @@
import os
import random
def tts_cache(root_path, meta_file):
"""This format is set for the meta-file generated by extract_features.py"""
txt_file = os.path.join(root_path, meta_file)
@@ -109,7 +110,23 @@ def nancy(root_path, meta_file):
for line in ttf:
id = line.split()[1]
text = line[line.find('"')+1:line.rfind('"')-1]
wav_file = root_path + 'wavn/' + id + '.wav'
wav_file = os.path.join(root_path, "wavn", id + ".wav")
items.append([text, wav_file])
random.shuffle(items)
return items
return items
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 = []
with open(txt_file, 'r') as ttf:
for line in ttf:
if line.startswith("client_id"):
continue
cols = line.split("\t")
text = cols[2]
# Files need to be first converted to wav...
wav_file = os.path.join(root_path, "clips", cols[1] + ".wav")
items.append([text, wav_file])
return items