本指南介绍如何手动下载 IndexTTS2 官方模型,适用于网络不稳定或自动下载失败的情况。
- 模型仓库:
IndexTeam/IndexTTS-2 - HuggingFace 链接: https://huggingface.co/IndexTeam/IndexTTS-2
- 模型大小: 约 5.9GB
- 本地存储路径:
checkpoints/(默认)
pip install huggingface-hubhuggingface-cli login# 在项目根目录执行
huggingface-cli download IndexTeam/IndexTTS-2 --local-dir checkpoints或者指定完整路径:
huggingface-cli download IndexTeam/IndexTTS-2 --local-dir ~/LearningFriend/checkpoints# Ubuntu/Debian
sudo apt-get install git-lfs
# macOS
brew install git-lfs
# 初始化 Git LFS
git lfs install# 在项目根目录执行
cd ~/LearningFriend
git clone https://huggingface.co/IndexTeam/IndexTTS-2 checkpoints如果已存在 checkpoints 目录,可以克隆到临时目录再移动:
git clone https://huggingface.co/IndexTeam/IndexTTS-2 checkpoints_temp
mv checkpoints_temp/* checkpoints/
rm -rf checkpoints_temp创建下载脚本 scripts/download_indextts2_manual.py:
#!/usr/bin/env python3
"""
手动下载 IndexTTS2 官方模型
"""
import os
from pathlib import Path
from huggingface_hub import snapshot_download
def download_models():
"""下载 IndexTTS2 官方模型"""
repo_id = "IndexTeam/IndexTTS-2"
local_dir = Path("checkpoints")
print(f"开始从 {repo_id} 下载模型...")
print(f"保存路径: {local_dir.absolute()}")
try:
snapshot_download(
repo_id=repo_id,
local_dir=str(local_dir),
local_dir_use_symlinks=False,
resume_download=True # 支持断点续传
)
print("✓ 模型下载完成!")
print(f"模型已保存到: {local_dir.absolute()}")
except Exception as e:
print(f"✗ 下载失败: {str(e)}")
print("\n提示:")
print("1. 检查网络连接")
print("2. 尝试使用镜像站点")
print("3. 使用其他下载方法(见文档)")
raise
if __name__ == "__main__":
download_models()运行脚本:
python scripts/download_indextts2_manual.py# 安装 ModelScope
pip install modelscope
# 下载模型
python -c "from modelscope.hub.snapshot_download import snapshot_download; snapshot_download('IndexTeam/IndexTTS-2', cache_dir='checkpoints')"或创建脚本:
from modelscope.hub.snapshot_download import snapshot_download
snapshot_download('IndexTeam/IndexTTS-2', cache_dir='checkpoints')下载完成后,检查以下文件是否都存在:
ls -lh checkpoints/应该包含:
config.yaml- 配置文件bpe.model- BPE 分词模型feat1.pt- 特征文件 1feat2.pt- 特征文件 2qwen0.6bemo4-merge/model-00001-of-00002.safetensors- Qwen 模型文件 1qwen0.6bemo4-merge/model-00002-of-00002.safetensors- Qwen 模型文件 2
下载完成后,重新运行测试:
python test_pipeline.py系统会自动检测 checkpoints/ 目录中的模型文件并使用它们。
解决方案:
- 使用国内镜像(ModelScope)
- 使用代理
- 分时段下载(避开高峰)
解决方案:
# huggingface-cli 支持断点续传,重新运行相同命令即可
huggingface-cli download IndexTeam/IndexTTS-2 --local-dir checkpoints解决方案:
# 检查磁盘空间
df -h
# 清理缓存(如果需要)
rm -rf ~/.cache/huggingface/解决方案:
# 确保有写入权限
chmod -R 755 checkpoints/
# 或使用 sudo(不推荐)
sudo chown -R $USER:$USER checkpoints/确保 config/config.yaml 中设置了正确的路径:
tts:
use_official: true
model_path: "checkpoints" # 模型目录
official_repo: "index-tts" # 官方代码仓库路径- 首次下载: 建议使用
huggingface-cli,速度较快且支持断点续传 - 国内用户: 使用 ModelScope 镜像下载速度更快
- 离线使用: 下载后可以将
checkpoints/目录备份,后续直接复制即可 - 版本管理: 模型文件较大,建议添加到
.gitignore,不要提交到 Git
- 已安装
huggingface-hub或modelscope - 已下载模型到
checkpoints/目录 - 已验证所有必需文件都存在
- 已配置正确的
config.yaml - 已成功运行测试
python test_pipeline.py