mirror of
https://github.com/wassname/TTS.git
synced 2026-09-09 11:16:00 +08:00
common voice preprocessor and tests, small refactoring within tests
This commit is contained in:
+19
-2
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user