基于 IndexTTS2 的声音克隆与文本转语音,开箱即用地运行在 CNB 云原生平台上
.
├── start.sh # WebUI 启动脚本
├── reference.py # Python API 调用示例
├── voices/ # 内置参考音频
│ ├── Arlecchino.mp3 # 阿蕾奇诺
│ ├── Columbina.mp3 # 哥伦比娅
│ └── Mizuki.mp3 # 梦见月瑞希
├── skills/indextts/ # NPC 声音克隆技能
├── configs/ # 配置文件
└── checkpoints/ # 模型文件(首次运行自动下载)
./start.sh
7860 会自动开启公网访问# 进入项目目录
cd /root/index-tts
# 激活虚拟环境
source .venv/bin/activate
# 运行示例
uv run reference.py
编辑 reference.py 自定义文本与参考音频:
from indextts.infer_v2 import IndexTTS2
tts = IndexTTS2(
cfg_path="/root/index-tts/checkpoints/config.yaml",
model_dir="/root/index-tts/checkpoints",
use_fp16=False,
use_cuda_kernel=False,
use_deepspeed=False,
)
text = "你好,欢迎使用 IndexTTS 声音克隆!"
tts.infer(
spk_audio_prompt="voices/Columbina.mp3", # 参考音频路径
text=text, # 要合成的文本
output_path="gen.wav", # 输出文件路径
verbose=True,
)
在仓库页面点击「洞察 → indextts」即可通过 NPC 对话进行语音合成,支持自然语言描述需求。
| 角色 | 音频文件 | 说明 |
|---|---|---|
| 阿蕾奇诺 | voices/Arlecchino.mp3 | 原神·仆人 |
| 哥伦比娅 | voices/Columbina.mp3 | 原神·少女 |
| 梦见月瑞希 | voices/Mizuki.mp3 | 原神·梦见月瑞希 |
你也可以使用自己的音频文件(支持 wav、mp3、ogg 等格式)作为参考音频。
| 参数 | 类型 | 说明 |
|---|---|---|
cfg_path | string | 配置文件路径 |
model_dir | string | 模型目录路径 |
use_fp16 | bool | 半精度推理,减少显存占用(需 GPU 支持) |
use_cuda_kernel | bool | CUDA 加速内核,显著提升推理速度 |
use_deepspeed | bool | DeepSpeed 加速(大型 GPU 推荐) |
| 参数 | 类型 | 说明 |
|---|---|---|
spk_audio_prompt | string | 参考音频路径,建议 5~30 秒清晰无噪音音频 |
text | string | 要合成的文本,支持中英文混合 |
output_path | string | 输出文件路径,默认 WAV 格式 |
verbose | bool | 显示详细推理信息 |
use_fp16=True 和 use_cuda_kernel=True 可大幅提升速度uv 管理)本项目基于原项目 License 开源,仅供学习交流使用。