這是AAAI-2024 Paper Unicats中CTX-TXT2VEC TTS模型的官方實施:統一的上下文感知的文本對語音框架,具有上下文的VQ-局限和錄音。

該倉庫在Linux上的Python 3.7上進行了測試。您可以使用Conda設置環境
# Install required packages
conda create -n ctxt2v python=3.7 # or any name you like
conda activate ctxt2v
pip install -r requirements.txt每次您輸入此項目時,都可以conda activate ctxt2v或source path.sh
另外,您可以執行chmod +x utils/*以確保這些SCIPT是可執行的。
例如,在這裡,我們以Libritts準備管道為例。其他數據集可以以相同的方式設置。
data/ 。內容如下: ├── train_all
│ ├── duration # the integer duration for each utterance. Frame shift is 10ms.
│ ├── feats.scp # the VQ index for each utterance. Will be explained later.
│ ├── text # the phone sequence for each utterance
│ └── utt2num_frames # the number of frames of each utterance.
├── eval_all
│ ... # similar four files
│── dev_all
│ ...
└── lang_1phn
└── train_all_units.txt # mapping between valid phones and their indexes
feats.scp是kaldi風格的功能指示符,指向feats/label/.../feats.ark 。我們還在線提供它(432MB),因此請下載並解壓縮到項目目錄中的feats 。這些功能是VQ-WAV2VEC功能的1D平坦索引。您可以通過utils/feat-to-shape.py scp:feats/label/dev_all/feats.scp | head 。 Codebook feats/vqidx/codebook.npy具有形狀[2, 320, 256] 。也就是說,我們使用Fairseq的VQ-WAV2VEC模型(Kmeans librispeech版本)提取了離散的代碼書INDXES,其中包含2組整數索引,每個索引範圍從0到319,我們在這些配對中的出現。然後,這些索引的出現,並使用另一個索引,該索引在此實驗室和原始Indere dobib tobib tobib tobib tobib tobib tobib tobib tob tobib tob tob tob tobib tobib tob tober index。
feats/vqidx/label2vqidx。我們使用23632標籤來訓練VQ-Diffusion模型。
正確構建目錄後,可以訓練模型。
培訓CTX-TXT2VEC模型可以簡單地完成
python train.py --name Libritts --config_file configs/Libritts.yaml --num_node 1 --tensorboard --auto_resume其中--name指定輸出目錄名稱。查看configs/Libritts.yaml以獲取詳細的配置。該程序會自動處理多GPU培訓(默認使用所有可見設備)。
培訓開始後,檢查點和日誌將保存在OUTPUT/Libritts中。
CTX-TXT2VEC的解碼始終取決於提供上下文信息的提示。換句話說,在解碼之前,應該有utt2prompt看起來像:
1089_134686_000002_000001 1089_134686_000032_000008
1089_134686_000007_000005 1089_134686_000032_000008
1089_134686_000009_000003 1089_134686_000032_000008
1089_134686_000009_000008 1089_134686_000032_000008
1089_134686_000015_000003 1089_134686_000032_000008
每行被組織為utt-to-synthesize prompt-utt 。 utt-to-synthesize and prompt-utt鍵都應以feats.scp用於索引。
我們建議在論文中使用官方的utt2 -prompt文件進行測試集B。您可以下載並保存到data/eval_all/utt2prompt 。
之後,可以通過上下文預處理(又稱延續)執行
python continuation.py --eval-set eval_all
# will only synthesize utterances in `utt2prompt`. Check the necessary files in `data/${eval_set}`.解碼的VQ-Indexes(2-DIM)將保存到OUTPUT/Libritts/syn/${eval_set}/ 。
請注意,該模型實際上是從23631不同的VQ“標籤”中取樣的。在此代碼中,我們使用
feats/vqidx/label2vqidx將其轉換回2-DIM VQ索引。
強烈建議使用輔助波形的作品編碼,“ CTX-VEC2WAV”。您可以通過
git clone https://github.com/cantabile-kwok/UniCATS-CTX-vec2wav.git然後遵循那裡的環境指導。
解碼為VQ索引後,可以通過
syn_dir= $PWD /OUTPUT/Libritts/syn/eval_all/
utt2prompt_file= $PWD /data/eval_all/utt2prompt
v2w_dir=/path/to/CTX-vec2wav/
cd $v2w_dir || exit 1 ;
source path.sh
# now, in CTX-vec2wav's environment
feat-to-len.py scp: $syn_dir /feats.scp > $syn_dir /utt2num_frames
# construct acoustic prompt specifier (mel spectrograms) using utt2prompt
python ./local/get_prompt_scp.py feats/normed_fbank/eval_all/feats.scp ${utt2prompt_file} > $syn_dir /prompt.scp
decode.py --feats-scp $syn_dir /feats.scp
--prompt-scp $syn_dir /prompt.scp
--num-frames $syn_dir /utt2num_frames
--outdir $syn_dir /wav/
--checkpoint /path/to/checkpoint在開發過程中,提到以下存儲庫:
ctx_text2vec/modeling/transformers/espnet_nets和實用程序utils中的模型體系結構。utils中的大多數實用腳本。