AI语音克隆

安装

下载安装github代码库

复制代码
git clone https://github.com/Plachtaa/VITS-fast-fine-tuning.git

安装文档
中日语言模型网站

目前支持的任务:

  • 从 10条以上的短音频 克隆角色声音
  • 从 3分钟以上的长音频(单个音频只能包含单说话人) 克隆角色声音
  • 从 3分钟以上的视频(单个视频只能包含单说话人) 克隆角色声音
  • 通过输入 bilibili视频链接(单个视频只能包含单说话人) 克隆角色声音

本地运行和推理

复制代码
python VC_inference.py --model_dir ./OUTPUT_MODEL/G_latest.pth --share True

这个时候在本地的浏览器打开网址

复制代码
http://localhost:7860

就可以看到语音tts的使用界面,但这只能在本地电脑能看到,如果要在远程的电脑上访问,可以使用cpolar

复制代码
cpolar http 7860

这个时候就会出现一个访问的网址链接。

本地训练

1.创建conda运行环境

复制代码
conda create -n tts python=3.8

2.安装环境依赖

复制代码
pip install -r requirements.txt

在这个过程中,有一部分安装包,比如OpenAI的whisper代码包,可能因为网络问题,而无法访问,无法使用pip进行网络安装。可以在其它地方,单独下载好代码包,然后使用pip单独安装本地包。

3.安装GPU版本的PyTorch

复制代码
# CUDA 11.6
pip install torch==1.13.1+cu116 torchvision==0.14.1+cu116 torchaudio==0.13.1 --extra-index-url https://download.pytorch.org/whl/cu116
# CUDA 11.7
pip install torch==1.13.1+cu117 torchvision==0.14.1+cu117 torchaudio==0.13.1 --extra-index-url https://download.pytorch.org/whl/cu117

4.安装视频模块包

复制代码
pip install imageio==2.4.1
pip install moviepy

5.构建预处理模块

复制代码
cd monotonic_align
mkdir monotonic_align
python setup.py build_ext --inplace
cd ..

6.下载辅助数据包

复制代码
mkdir pretrained_models
# download data for fine-tuning
wget https://huggingface.co/datasets/Plachta/sampled_audio4ft/resolve/main/sampled_audio4ft_v2.zip
unzip sampled_audio4ft_v2.zip
# create necessary directories
mkdir video_data
mkdir raw_audio
mkdir denoised_audio
mkdir custom_character_voice
mkdir segmented_character_voice

7.下载预训练模型

复制代码
CJE: Trilingual (Chinese, Japanese, English)
CJ: Dualigual (Chinese, Japanese)
C: Chinese only

wget https://huggingface.co/spaces/Plachta/VITS-Umamusume-voice-synthesizer/resolve/main/pretrained_models/D_trilingual.pth -O ./pretrained_models/D_0.pth
wget https://huggingface.co/spaces/Plachta/VITS-Umamusume-voice-synthesizer/resolve/main/pretrained_models/G_trilingual.pth -O ./pretrained_models/G_0.pth
wget https://huggingface.co/spaces/Plachta/VITS-Umamusume-voice-synthesizer/resolve/main/configs/uma_trilingual.json -O ./configs/finetune_speaker.json

wget https://huggingface.co/spaces/sayashi/vits-uma-genshin-honkai/resolve/main/model/D_0-p.pth -O ./pretrained_models/D_0.pth
wget https://huggingface.co/spaces/sayashi/vits-uma-genshin-honkai/resolve/main/model/G_0-p.pth -O ./pretrained_models/G_0.pth
wget https://huggingface.co/spaces/sayashi/vits-uma-genshin-honkai/resolve/main/model/config.json -O ./configs/finetune_speaker.json

wget https://huggingface.co/datasets/Plachta/sampled_audio4ft/resolve/main/VITS-Chinese/D_0.pth -O ./pretrained_models/D_0.pth
wget https://huggingface.co/datasets/Plachta/sampled_audio4ft/resolve/main/VITS-Chinese/G_0.pth -O ./pretrained_models/G_0.pth
wget https://huggingface.co/datasets/Plachta/sampled_audio4ft/resolve/main/VITS-Chinese/config.json -O ./configs/finetune_speaker.json

8.将语音数据放置在对应的文件目录

  • 短语音
    将多段语音打包成zip文件,文件结构为

    Your-zip-file.zip
    ├───Character_name_1
    ├ ├───xxx.wav
    ├ ├───...
    ├ ├───yyy.mp3
    ├ └───zzz.wav
    ├───Character_name_2
    ├ ├───xxx.wav
    ├ ├───...
    ├ ├───yyy.mp3
    ├ └───zzz.wav
    ├───...

    └───Character_name_n
    ├───xxx.wav
    ├───...
    ├───yyy.mp3
    └───zzz.wav

将打包文件放置在./custom_character_voice/

运行

复制代码
unzip ./custom_character_voice/custom_character_voice.zip -d ./custom_character_voice/
  • 长语音
    将wav格式的语音命名为Diana_234135.wav,放置在./raw_audio/
  • 视频
    将视频命名为Taffy_332452.mp4,放置在./video_data/

9.处理音频

复制代码
python scripts/video2audio.py
python scripts/denoise_audio.py
python scripts/long_audio_transcribe.py --languages "{PRETRAINED_MODEL}" --whisper_size large
python scripts/short_audio_transcribe.py --languages "{PRETRAINED_MODEL}" --whisper_size large
python scripts/resample.py

注意将"{PRETRAINED_MODEL}"替换为"C",如果GPU内存没有12GB,将whisper_size替换为medium或small。

10.处理文本数据

选择对应的辅助数据包,运行

复制代码
python preprocess_v2.py --add_auxiliary_data True --languages "C"

如果不选择辅助数据包,运行

复制代码
python preprocess_v2.py --languages "{PRETRAINED_MODEL}"

11.开始训练

运行命令,开始训练

复制代码
python finetune_speaker_v2.py -m ./OUTPUT_MODEL --max_epochs "{Maximum_epochs}" --drop_speaker_embed True

如果是从一个训练过的模型,开始继续训练

复制代码
python finetune_speaker_v2.py -m ./OUTPUT_MODEL --max_epochs "{Maximum_epochs}" --drop_speaker_embed False --cont True

12.清除语音数据

复制代码
rm -rf ./custom_character_voice/* ./video_data/* ./raw_audio/* ./denoised_audio/* ./segmented_character_voice/* ./separated/* long_character_anno.txt short_character_anno.txt

del /Q /S .\custom_character_voice\* .\video_data\* .\raw_audio\* .\denoised_audio\* .\segmented_character_voice\* .\separated\* long_character_anno.txt short_character_anno.txt
相关推荐
一只落魄的蜂鸟2 分钟前
《图解技术体系》Wonderful talk AI ~~GPT
人工智能·gpt
DisonTangor2 分钟前
【2B篇】阿里通义 Qwen3-VL 新增 2B、32B 两个模型尺寸,手机也能轻松运行
人工智能·计算机视觉·语言模型·开源·aigc
Francek Chen5 分钟前
【自然语言处理】预训练01:词嵌入(word2vec)
人工智能·自然语言处理·word2vec
Dongsheng_201912 分钟前
【手机篇】AI深度学习在手机摄像头模组支架外观检测应用方案
人工智能·智能手机
郝学胜-神的一滴23 分钟前
主成分分析(PCA)在计算机图形学中的深入解析与应用
开发语言·人工智能·算法·机器学习·1024程序员节
飞哥数智坊35 分钟前
想用好 AI 编程?你可能得先学点管理
人工智能·ai编程
golang学习记37 分钟前
太卷了,蚂蚁又发布了新一代Code Agent!
人工智能
StarPrayers.1 小时前
神经网络中的 HWC→CHW 格式转换
人工智能·深度学习·神经网络
ModelWhale1 小时前
和鲸科技入选《大模型一体机产业图谱》,以一体机智驱科研、重塑教学
人工智能·科研·高等教育
区块block2 小时前
DeFi中的自主代理:用AI重塑金融
人工智能·金融