这是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中的大多数实用脚本。