目录
基于Tacotron1的中文语音合成 TTS
本文主要demo 基于tacotron1的中文语音合成结果与实现,所用语料库为:data_thchs30
中文发音git参考 (本文引用)
一、window部署环境
- conda下的python3.6
- tf 1.14.0
- Cuda 10.0
- Cudann 7.4
- librosa 0.6.1 (0.5.1有点问题)
- Windows tf各个版本与cuda,cudann配对
二、复现
1.前处理要点
begeekmyfriend /tacotron/tree/mandarin 的 datasets 中 thchs30.py 34 行 注释掉‘.wav’:
wav_file = trn[:-4] + '.wav' 改为: wav_file = trn[:-4]
datasets 中 thchs30.py 29 行 'biaobei_48000' 替换成你训练资料的目录, 以data_thchs30可以换成data 或者train
https://www.vocabulary.com/lists/6974420
trn_files = glob.glob(os.path.join(in_dir, 'biaobei_48000', '*.trn'))
trn_files = glob.glob(os.path.join(in_dir, 'data', '*.trn'))
注意:如果是以tarin为目录,train中的trn是指向data的文件路径,而非训练所需要的拼音,如果这部分没处理好会影响后续模型的训练。
如果是data_thchs30 可以将这一段替换原本代码,原本代码中有点小问题,没能提出到训练所需的拼音音标
-
def build_from_path(in_dir, out_dir, num_workers=1, tqdm=lambda x: x):
-
executor = ProcessPoolExecutor(max_workers=num_workers)
-
futures = []
-
index = 1
-
trn_files = glob.glob(os.path.join(in_dir, 'data', '*.trn'))
-
for trn in trn_files:
-
with open(trn,encoding='utf-8') as f:
-
content = f.readline().strip('\n')
-
#print("content",content)
-
pinyin = f.readline().strip('\n')
-
wav_file = trn[:-4]# + '.wav'
-
#print("pinyin",pinyin)
-
#print("wav_file",wav_file)
-
task = partial(_process_utterance, out_dir, index, wav_file, pinyin)
-
futures.append(executor.submit(task))
-
index += 1
-
return [future.result() for future in tqdm(futures) if future.result() is not None]
正确的前处理结果
2.训练收敛与结果demo
2.4w次训练大概收敛到0.6左右,运行eval.py已经能够合成带有杂音的声音,同时音频图也对齐,下图为对齐的音频图
https://www.vocabulary.com/lists/6975993
音频部分的demo