該存儲庫包含一個擴展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參數指定的路徑中。