
基於卷積網絡基於文本到語音綜合模型的Pytorch實現:
音頻樣本可在https://r9y9.github.io/deepvoice3_pytorch/上找到。
筆記本應該在https://colab.research.google.com上執行:
注意:驗證的模型與主體不兼容。即將更新。
| URL | 模型 | 數據 | 超級參數 | git提交 | 步驟 |
|---|---|---|---|---|---|
| 關聯 | DeepVoice3 | ljspeech | 關聯 | ABF0A21 | 640k |
| 關聯 | Nyanko | ljspeech | builder=nyanko,preset=nyanko_ljspeech | BA59DC7 | 585k |
| 關聯 | 多演講者DeepVoice3 | VCTK | builder=deepvoice3_multispeaker,preset=deepvoice3_vctk | 0421749 | 300k + 300k |
要使用預訓練的模型,強烈建議您使用上述特定的git訂單。 IE,
git checkout ${commit_hash}
然後遵循“從檢查點的合成”部分,在“特定git commit”的讀書中。請注意,最新的開發版本可能無法使用。
您可以嘗試:
# pretrained model (20180505_deepvoice3_checkpoint_step000640000.pth)
# hparams (20180505_deepvoice3_ljspeech.json)
git checkout 4357976
python synthesis.py --preset=20180505_deepvoice3_ljspeech.json
20180505_deepvoice3_checkpoint_step000640000.pth
sentences.txt
output_dir
hparams.py 。builder指定您要使用的型號。 deepvoice3 , deepvoice3_multispeaker [1]和nyanko [2]被覆蓋。請首先安裝上面列出的軟件包,然後
git clone https://github.com/r9y9/deepvoice3_pytorch && cd deepvoice3_pytorch
pip install -e ".[bin]"
有許多超級參數要轉動取決於您正在使用的模型和數據。對於典型的數據集和模型,存儲庫中提供了已知工作良好的參數(預設)。有關詳細信息,請參見presets目錄。注意
preprocess.pytrain.pysynthesis.py接受--preset=<json>可選參數,該參數指定在哪裡加載預設參數。如果要使用預設參數,則必須在整個預處理,培訓和評估中使用相同的--preset=<json> 。例如,
python preprocess.py --preset=presets/deepvoice3_ljspeech.json ljspeech ~/data/LJSpeech-1.0
python train.py --preset=presets/deepvoice3_ljspeech.json --data-root=./data/ljspeech
而不是
python preprocess.py ljspeech ~/data/LJSpeech-1.0
# warning! this may use different hyper parameters used at preprocessing stage
python train.py --preset=presets/deepvoice3_ljspeech.json --data-root=./data/ljspeech
用法:
python preprocess.py ${dataset_name} ${dataset_path} ${out_dir} --preset=<json>
支持的${dataset_name} s是:
ljspeech (en,單揚聲器)vctk (EN,多演講者)jsut (JP,單人揚聲器)nikl_m (KO,多演講者)nikl_s (KO,單揚聲器)假設您使用已知的預設參數可用於ljspeech數據集/deepVoice3,並且在~/data/LJSpeech-1.0中具有數據,則可以通過以下方式進行預處理數據
python preprocess.py --preset=presets/deepvoice3_ljspeech.json ljspeech ~/data/LJSpeech-1.0/ ./data/ljspeech
完成此操作後,您將在./data/ljspeech中看到提取的功能(MEL-SPECTROGINS和線性譜圖)。
目前支持使用JSON格式的元數據(與CARPEDM20/Multi-E-Takotron-TensorFlow)建立自己的數據集。用法:
python preprocess.py json_meta ${list-of-JSON-metadata-paths} ${out_dir} --preset=<json>
您可能需要修改預先存在的預設JSON文件,尤其是n_speakers 。對於英語MultiSpeaker,請從presets/deepvoice3_vctk.json開始。
假設您有數據集A(揚聲器A)和數據集B(揚聲器B),則每個數據集在JSON Metadata File ./datasets/datasetA/alignment.json and ./datasets/datasetB/alignment.json中進行了描述。
python preprocess.py json_meta "./datasets/datasetA/alignment.json,./datasets/datasetB/alignment.json" "./datasets/processed_A+B" --preset=(path to preset json file)
一些數據集,尤其是自動生成的數據集可能包括長時間的沉默和不良的前導/尾聲噪聲,從而破壞了char-Level SEQ2SEQ模型。 (例如,VCTK,儘管它用VCTK_PREPROCESS涵蓋)
為了解決問題, gentle_web_align.py將
gentle_web_align.py使用Gentle,一種基於Kaldi的語音文本對齊工具。這訪問了網絡安裝的溫和應用程序,對成績單的聲音段對齊,並將結果轉換為htk式標籤文件,並在preprocess.py中處理。溫和可以在Linux/Mac/Windows(通過Docker)中運行。
初步結果表明,雖然vctk_preprocess/prepare_vctk_labels.py在VCTK上的htk/Festival/基於Merlin的方法在VCTK上的工作效果更好,但柔和的音頻剪輯具有帶有環境噪音的音頻剪輯。 (例如電影摘錄)
用法:(假設溫柔在localhost:8567 (未指定時默認值))
datasetA/wavs和成績單位於datasetA/txts ) python gentle_web_align.py -w "datasetA/wavs/*.wav" -t "datasetA/txts/*.txt" --server_addr=localhost --port=8567
datasetB/speakerN/blahblah.wav和datasetB/speakerN/blahblah.txt ) python gentle_web_align.py --nested-directories="datasetB" --server_addr=localhost --port=8567
每種話語都具有音素對齊後,您可以通過運行preprocess.py提取功能
用法:
python train.py --data-root=${data-root} --preset=<json> --hparams="parameters you may want to override"
假設您使用LJSpeech數據集構建DeepVoice3風格的模型,然後可以通過以下方式訓練您的模型
python train.py --preset=presets/deepvoice3_ljspeech.json --data-root=./data/ljspeech/
默認情況下,模型檢查點(.pth)和對齊(.png ./checkpoints保存在每10000個步驟中。
請先檢查一下,然後按照以下命令進行檢查。
python preprocess.py nikl_s ${your_nikl_root_path} data/nikl_s --preset=presets/deepvoice3_nikls.json
python train.py --data-root=./data/nikl_s --checkpoint-dir checkpoint_nikl_s --preset=presets/deepvoice3_nikls.json
默認情況下,將日誌傾倒在./log目錄中。您可以通過張板監視日誌:
tensorboard --logdir=log
給定文本列表, synthesis.py合成了訓練有素的模型的音頻信號。用法是:
python synthesis.py ${checkpoint_path} ${text_list.txt} ${output_dir} --preset=<json>
示例test_list.txt:
Generative adversarial network or variational auto-encoder.
Once upon a time there was a dear little girl who was loved by every one who looked at her, but most of all by her grandmother, and there was nothing that she would not have given to the child.
A text-to-speech synthesis system typically consists of multiple stages, such as a text analysis frontend, an acoustic model and an audio synthesis module.
VCTK和NIKL受支持用於構建多演講型模型的數據集。
由於VCTK中的某些音頻樣本會影響性能長時間,因此建議進行音素對齊並根據VCTK_PREPROCESS去除沉默。
一旦對每種話語進行音素對齊,就可以通過以下方式提取功能:
python preprocess.py vctk ${your_vctk_root_path} ./data/vctk
現在您準備了數據,然後您可以通過以下方式培訓DeepVoice3的多演講者版本
python train.py --data-root=./data/vctk --checkpoint-dir=checkpoints_vctk
--preset=presets/deepvoice3_vctk.json
--log-event-path=log/deepvoice3_multispeaker_vctk_preset
如果您想重用從其他數據集中學習的學習嵌入,則可以通過:
python train.py --data-root=./data/vctk --checkpoint-dir=checkpoints_vctk
--preset=presets/deepvoice3_vctk.json
--log-event-path=log/deepvoice3_multispeaker_vctk_preset
--load-embedding=20171213_deepvoice3_checkpoint_step000210000.pth
這可能會提高訓練速度。
您將能夠在../ nikl_preprocoess中獲得清理的音頻樣本。詳細信息在此處找到。
一旦Nikl語料庫準備從預處理中使用,您就可以通過以下方式提取功能
python preprocess.py nikl_m ${your_nikl_root_path} data/nikl_m
現在您準備了數據,然後您可以通過以下方式培訓DeepVoice3的多演講者版本
python train.py --data-root=./data/nikl_m --checkpoint-dir checkpoint_nikl_m
--preset=presets/deepvoice3_niklm.json
如果您的數據非常有限,則可以考慮嘗試微調預訓練的模型。例如,使用LJSpeech上的預訓練模型,您可以通過以下命令將其調整為VCTK揚聲器p225 (30分鐘)的數據:
python train.py --data-root=./data/vctk --checkpoint-dir=checkpoints_vctk_adaptation
--preset=presets/deepvoice3_ljspeech.json
--log-event-path=log/deepvoice3_vctk_adaptation
--restore-parts="20171213_deepvoice3_checkpoint_step000210000.pth"
--speaker-id=0
根據我的經驗,它可以很快獲得合理的語音質量,而不是從頭開始訓練模型。
上面有兩個重要的選項:
--restore-parts=<N> :它指定了加載模型參數的位置。選項--checkpoint=<N>的差異為1) --restore-parts=<N>忽略所有無效的參數,而--checkpoint=<N>則沒有。 2) --restore-parts=<N>告訴教練從0步啟動,而--checkpoint=<N>告訴教練從最後一步開始。 --checkpoint=<N>如果您使用完全相同的型號並繼續訓練,則應該可以,但是如果您想自定義模型體系結構並獲得預訓練的模型,那將是有用的。--speaker-id=<N> :它指定數據使用者用於培訓。僅當您使用多演講者數據集時,才能指定這一點。至於VCTK,根據數據集中的speaker_info.txt ,將自動分配揚聲器ID(0,1,...,107)。如果您正在培訓多演講型模型,則只有在n_speakers相同的情況下,揚聲器的改編才能起作用。
這可能會根據Matplotlib的後端而定。嘗試更改matplotlib的後端,看看它是否工作如下:
MPLBACKEND=Qt5Agg python train.py ${args...}
在#78中,Engiecat報告說,將Matplotlib的後端從TKINTER(TKAGG)更改為PYQT5(QT5AGG)解決了問題。
代碼的一部分是根據以下項目改編的:
@jraulhernandezi創建的橫幅和徽標(#76)