mirror of https://github.com/coqui-ai/TTS.git
removed shuffling of data in the preprocessor, uniform indentation
This commit is contained in:
parent
41e3e42989
commit
f279fe9e8b
|
@ -1,5 +1,4 @@
|
||||||
import os
|
import os
|
||||||
import random
|
|
||||||
|
|
||||||
|
|
||||||
def tts_cache(root_path, meta_file):
|
def tts_cache(root_path, meta_file):
|
||||||
|
@ -9,8 +8,8 @@ def tts_cache(root_path, meta_file):
|
||||||
with open(txt_file, 'r', encoding='utf8') as f:
|
with open(txt_file, 'r', encoding='utf8') as f:
|
||||||
for line in f:
|
for line in f:
|
||||||
cols = line.split('| ')
|
cols = line.split('| ')
|
||||||
items.append(cols) # text, wav_full_path, mel_name, linear_name, wav_len, mel_len
|
# text, wav_full_path, mel_name, linear_name, wav_len, mel_len
|
||||||
random.shuffle(items)
|
items.append(cols)
|
||||||
return items
|
return items
|
||||||
|
|
||||||
|
|
||||||
|
@ -23,10 +22,9 @@ def tweb(root_path, meta_file):
|
||||||
with open(txt_file, 'r') as ttf:
|
with open(txt_file, 'r') as ttf:
|
||||||
for line in ttf:
|
for line in ttf:
|
||||||
cols = line.split('\t')
|
cols = line.split('\t')
|
||||||
wav_file = os.path.join(root_path, cols[0]+'.wav')
|
wav_file = os.path.join(root_path, cols[0] + '.wav')
|
||||||
text = cols[1]
|
text = cols[1]
|
||||||
items.append([text, wav_file])
|
items.append([text, wav_file])
|
||||||
random.shuffle(items)
|
|
||||||
return items
|
return items
|
||||||
|
|
||||||
|
|
||||||
|
@ -44,48 +42,48 @@ def tweb(root_path, meta_file):
|
||||||
|
|
||||||
|
|
||||||
def mozilla(root_path, meta_files):
|
def mozilla(root_path, meta_files):
|
||||||
"""Normalizes Mozilla meta data files to TTS format"""
|
"""Normalizes Mozilla meta data files to TTS format"""
|
||||||
import glob
|
import glob
|
||||||
meta_files = glob.glob(root_path + "/**/batch*.txt", recursive=True)
|
meta_files = glob.glob(root_path + "/**/batch*.txt", recursive=True)
|
||||||
folders = [os.path.dirname(f.strip()) for f in meta_files]
|
folders = [os.path.dirname(f.strip()) for f in meta_files]
|
||||||
items = []
|
items = []
|
||||||
for idx, meta_file in enumerate(meta_files):
|
for idx, meta_file in enumerate(meta_files):
|
||||||
folder = folders[idx]
|
folder = folders[idx]
|
||||||
txt_file = os.path.join(root_path, meta_file)
|
txt_file = os.path.join(root_path, meta_file)
|
||||||
with open(txt_file, 'r') as ttf:
|
with open(txt_file, 'r') as ttf:
|
||||||
for line in ttf:
|
for line in ttf:
|
||||||
cols = line.split('|')
|
cols = line.split('|')
|
||||||
wav_file = os.path.join(root_path, folder, 'wavs_no_processing', cols[1].strip())
|
wav_file = os.path.join(root_path, folder, 'wavs_no_processing',
|
||||||
if os.path.isfile(wav_file):
|
cols[1].strip())
|
||||||
text = cols[0].strip()
|
if os.path.isfile(wav_file):
|
||||||
items.append([text, wav_file])
|
text = cols[0].strip()
|
||||||
else:
|
items.append([text, wav_file])
|
||||||
print(" > Error: {}".format(cols))
|
else:
|
||||||
continue
|
print(" > Error: {}".format(cols))
|
||||||
random.shuffle(items)
|
continue
|
||||||
return items
|
return items
|
||||||
|
|
||||||
|
|
||||||
def mailabs(root_path, meta_files):
|
def mailabs(root_path, meta_files):
|
||||||
"""Normalizes M-AI-Labs meta data files to TTS format"""
|
"""Normalizes M-AI-Labs meta data files to TTS format"""
|
||||||
folders = [os.path.dirname(f.strip()) for f in meta_files.split(",")]
|
folders = [os.path.dirname(f.strip()) for f in meta_files.split(",")]
|
||||||
meta_files = [f.strip() for f in meta_files.split(",")]
|
meta_files = [f.strip() for f in meta_files.split(",")]
|
||||||
items = []
|
items = []
|
||||||
for idx, meta_file in enumerate(meta_files):
|
for idx, meta_file in enumerate(meta_files):
|
||||||
print(" | > {}".format(meta_file))
|
print(" | > {}".format(meta_file))
|
||||||
folder = folders[idx]
|
folder = folders[idx]
|
||||||
txt_file = os.path.join(root_path, meta_file)
|
txt_file = os.path.join(root_path, meta_file)
|
||||||
with open(txt_file, 'r') as ttf:
|
with open(txt_file, 'r') as ttf:
|
||||||
for line in ttf:
|
for line in ttf:
|
||||||
cols = line.split('|')
|
cols = line.split('|')
|
||||||
wav_file = os.path.join(root_path, folder, 'wavs', cols[0]+'.wav')
|
wav_file = os.path.join(root_path, folder, 'wavs',
|
||||||
if os.path.isfile(wav_file):
|
cols[0] + '.wav')
|
||||||
text = cols[1]
|
if os.path.isfile(wav_file):
|
||||||
items.append([text, wav_file])
|
text = cols[1]
|
||||||
else:
|
items.append([text, wav_file])
|
||||||
continue
|
else:
|
||||||
random.shuffle(items)
|
continue
|
||||||
return items
|
return items
|
||||||
|
|
||||||
|
|
||||||
def ljspeech(root_path, meta_file):
|
def ljspeech(root_path, meta_file):
|
||||||
|
@ -95,10 +93,9 @@ def ljspeech(root_path, meta_file):
|
||||||
with open(txt_file, 'r') as ttf:
|
with open(txt_file, 'r') as ttf:
|
||||||
for line in ttf:
|
for line in ttf:
|
||||||
cols = line.split('|')
|
cols = line.split('|')
|
||||||
wav_file = os.path.join(root_path, 'wavs', cols[0]+'.wav')
|
wav_file = os.path.join(root_path, 'wavs', cols[0] + '.wav')
|
||||||
text = cols[1]
|
text = cols[1]
|
||||||
items.append([text, wav_file])
|
items.append([text, wav_file])
|
||||||
random.shuffle(items)
|
|
||||||
return items
|
return items
|
||||||
|
|
||||||
|
|
||||||
|
@ -109,10 +106,9 @@ def nancy(root_path, meta_file):
|
||||||
with open(txt_file, 'r') as ttf:
|
with open(txt_file, 'r') as ttf:
|
||||||
for line in ttf:
|
for line in ttf:
|
||||||
id = line.split()[1]
|
id = line.split()[1]
|
||||||
text = line[line.find('"')+1:line.rfind('"')-1]
|
text = line[line.find('"') + 1:line.rfind('"') - 1]
|
||||||
wav_file = os.path.join(root_path, "wavn", id + ".wav")
|
wav_file = os.path.join(root_path, "wavn", id + ".wav")
|
||||||
items.append([text, wav_file])
|
items.append([text, wav_file])
|
||||||
random.shuffle(items)
|
|
||||||
return items
|
return items
|
||||||
|
|
||||||
|
|
||||||
|
@ -126,7 +122,6 @@ def common_voice(root_path, meta_file):
|
||||||
continue
|
continue
|
||||||
cols = line.split("\t")
|
cols = line.split("\t")
|
||||||
text = cols[2]
|
text = cols[2]
|
||||||
# Files need to be first converted to wav...
|
|
||||||
wav_file = os.path.join(root_path, "clips", cols[1] + ".wav")
|
wav_file = os.path.join(root_path, "clips", cols[1] + ".wav")
|
||||||
items.append([text, wav_file])
|
items.append([text, wav_file])
|
||||||
return items
|
return items
|
||||||
|
|
Loading…
Reference in New Issue