该存储库包含一个扩展Pytorch 21.02-PY3 NGC容器的Dockerfile,并封装了一些依赖关系。要创建自己的容器,请从Nvidia Pytorch容器版本中选择一个Pytorch容器,然后创建一个Dockerfile,作为以下格式:
FROM nvcr . io / nvidia / pytorch : 21.02 - py3
WORKDIR / path / to / working / directory / text2speech /
COPY requirements . txt .
RUN pip install - r requirements . txt转到/path/to/working/directory/text2speech/docker
$ docker build - - no - cache - t torcht2s .
$ docker run - it - - rm - - gpus all - p 2222 : 8888 - v / path / to / working / directory / text2speech : / path / to / working / directory / text2speech torcht2s$ python - m ipykernel install - - user - - name = torcht2s
$ jupyter notebook - - ip = 0.0 . 0.0 - - port = 8888 - - no - browser - - allow - roothttp://127.0.0.1:2222/?token=${TOKEN} ,然后输入您在终端中指定的令牌。为了训练语音合成模型,需要表达声音的声音和音素序列。这是第一步中的WYH,将输入文本编码为符号列表。在这项研究中,我们将使用土耳其角色和音素作为符号。由于土耳其语是一种语音语言,因此在阅读时会表达单词。也就是说,字符序列是在土耳其语中构造的单词。在非语音语言(例如英语)中,可以用音素表示单词。要将土耳其语音与英语数据合成,英语数据集中的单词必须首先用语音转换为土耳其语。
valid_symbols = [ '1' , '1:' , '2' , '2:' , '5' , 'a' , 'a:' , 'b' , 'c' , 'd' , 'dZ' , 'e' , 'e:' , 'f' , 'g' , 'gj' , 'h' , 'i' , 'i:' , 'j' ,
'k' , 'l' , 'm' , 'n' , 'N' , 'o' , 'o:' , 'p' , 'r' , 's' , 'S' , 't' , 'tS' , 'u' , 'u' , 'v' , 'y' , 'y:' , 'z' , 'Z' ]为了加快培训,可以在预处理步骤中生成这些培训,并在培训期间直接从磁盘上阅读。请按照以下步骤使用自定义数据集。
text2speech/Fastpitch/dataset/ location的路径进行准备。这些filelists应列出每行单一的话语: < audio file path > | < transcript >text2speech/Fastpitch/data_preperation.ipynb $ python prepare_dataset . py
- - wav - text - filelists dataset / tts_data . txt
- - n - workers 16
- - batch - size 1
- - dataset - path dataset
- - extract - pitch
- - f0 - method pyin
- - extract - mels text2speech/Fastpitch/data_preperation.ipynb这些filelists列出每行的单一话语,准备了使用路径的文件列表,以通往预计的螺距来运行create_picth_text_file(manifest_path) 。 < mel or wav file path > | < pitch file path > | < text > | < speaker_id >完整的数据集具有以下结构:
. / dataset
├── mels
├── pitch
├── wavs
├── tts_data . txt # train + val
├── tts_data_train . txt
├── tts_data_val . txt
├── tts_pitch_data . txt # train + val
├── tts_pitch_data_train . txt
├── tts_pitch_data_val . txt该培训将产生一种能够从原始文本生成MEL-SPECTROGRAGIN的快速模型。它将被序列化为单个.pt检查点文件,以及一系列中间检查点。
$ python train . py - - cuda - - amp - - p - arpabet 1.0 - - dataset - path dataset
- - output saved_fastpicth_models /
- - training - files dataset / tts_pitch_data_train . txt
- - validation - files dataset / tts_pitch_data_val . txt
- - epochs 1000 - - learning - rate 0.001 - - batch - size 32
- - load - pitch - from - disk最后一步是将频谱图转换为波形。从频谱图生成语音的过程也称为Vocoder。
一些MEL光谱发电机容易建模偏差。由于频谱图与HIFI-GAN训练的真实数据不同,因此生成的音频的质量可能会受到影响。为了克服此问题,可以在特定的MEL光谱发电机的输出上微调HIFI-GAN模型,以适应此偏差。在本节中,我们将对FastPitch输出进行微调。
text2speech/Hifigan/data/pretrained_fastpicth_model/目录中复制最佳性能快速输出.pt文件。text2speech/Hifigan/data/ Directory中复制清单文件tts_pitch_data.txt 。 $ python extract_mels . py - - cuda
- o data / mels - fastpitch - tr22khz
- - dataset - path / text2speech / Fastpitch / dataset
- - dataset - files data / tts_pitch_data . txt # train + val
- - load - pitch - from - disk
- - checkpoint - path data / pretrained_fastpicth_model / FastPitch_checkpoint . pt - bs 16现在应在text2speech/Hifigan/data/mels-fastpitch-tr22khz目录中准备MEL-SPECTROGRAM。微调脚本将加载现有的HIFI-GAN模型,并使用最后一步中生成的频谱图运行几个训练时期。
此步骤将生成另一个.pt Hifi-GAN模型检查点文件,该文件对特定的FastPitch模型进行了微调。
text2speech/Hifigan目录中的results 。 $ nohup python train . py - - cuda - - output / results / hifigan_tr22khz
- - epochs 1000 - - dataset_path / Fastpitch / dataset
- - input_mels_dir / data / mels - fastpitch - tr22khz
- - training_files / Fastpitch / dataset / tts_data . txt
- - validation_files / Fastpitch / dataset / tts_data . txt
- - fine_tuning - - fine_tune_lr_factor 3 - - batch_size 16
- - learning_rate 0.0003 - - lr_decay 0.9998 - - validation_interval 10 > log . txt$ tail - f log . txt 运行以下命令与MEL-SPECTROGRAM GERTATOR合成原始文本的音频
python inference . py - - cuda
- - hifigan / Hifigan / results / hifigan_tr22khz / hifigan_gen_checkpoint . pt
- - fastpitch / Fastpitch / saved_fastpicth_models / FastPitch_checkpoint . pt
- i test_text . txt
- o wavs /语音是从与-i参数传递的文件中生成的。输出音频将存储在-o参数指定的路径中。