下载源码

安装Git和Git LFS(Git的一个扩展)

git lfs install
# 切换到你想存放源码的目录
cd E:\Python

# 拉取代码,并且重命名文件夹为 indextts2
git clone https://github.com/index-tts/index-tts.git indextts2 

# 切换到 indextts2 目录
cd indextts2

# 下载仓库里LFS管理的文件
git lfs pull

安装依赖

# 安装 uv 包管理器
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"

# 验证是否安装成功:重新打开一个powershell窗口执行
uv --version

Windows环境,修改indextts2/pyproject.toml,注释以下两项

# deepspeed = [
#  "deepspeed==0.17.1",
# ]

# no-build-isolation-package = ["deepspeed"]
uv python install 3.10      # 安装python解释器,指定版本,项目要求>=3.10
uv python pin 3.10          # 项目锁定版本
uv venv                     # 创建虚拟环境
uv sync --all-extras --default-index "https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple"        # 安装项目依赖,并指定使用清华的镜像

下载IndexTTS2模型

# 安装可执行的命令行工具 modelscope
uv tool install "modelscope"

# 执行命令前确保目录是在indextts的工程目录下,这样才会把模型下到工程目录里的checkpoints下面,比如我的:(base) PS D:\ruanjian\indextts2>

# 下载IndexTTS2模型,并且指定下载到checkpoints目录
modelscope download --model IndexTeam/IndexTTS-2 --local_dir checkpoints

运行项目

# 检查本机环境的CUDA和GPU是否可用
uv run tools/gpu_check.py

# 运行WebUI
uv run webui.py

使用IndexTTS2

打开浏览器访问http://127.0.0.1:7860

按照以上步骤操作,执行uv run webui.py命令后可能会遇到的问题

OSError: We couldn't connect to 'https://huggingface.co' to load the files, and couldn't find them in the cached files.
Checkout your internet connection or see how to run the library in offline mode at 'https://huggingface.co/docs/transformers/installation#offline-mode'.

这里就需要设置环境变量

右键「此电脑」→「属性」→「高级系统设置」→「环境变量」
在「用户变量」或「系统变量」中,点击「新建」,分别添加:

变量名:HF_ENDPOINT,变量值:https://hf-mirror.com
变量名:HF_HUB_ENABLE_HF_TRANSFER,变量值:1
OSError: Can't load feature extractor for 'facebook/w2v-bert-2.0'. If you were trying to load it from 'https://huggingface.co/models', make sure you don't have a local directory with the same name. Otherwise, make sure 'facebook/w2v-bert-2.0' is the correct path to a directory containing a preprocessor_config.json file

这里需要清理损坏的缓存并重新下载放置

1. 进入C:\Users\你的用户名\.cache\huggingface\hub,找到并删除名为 models--facebook--w2v-bert-2.0 的文件夹

2. 在浏览器中打开 https://hf-mirror.com/facebook/w2v-bert-2.0
点击 Files and versions 标签页,下载该页面上的所有文件,将它们放入到
.cache/huggingface/hub/
└── models--facebook--w2v-bert-2.0/
    └── snapshots/
        └── a1b2c3d.../  <-- 这个文件夹名字可以是任意的,比如用一个随机的哈希值或日期
            ├── config.json
            ├── preprocessor_config.json
            ├── pytorch_model.bin
            └── ... (其他所有下载的文件)
raise ValueError(
ValueError: Fast download using 'hf_transfer' is enabled (HF_HUB_ENABLE_HF_TRANSFER=1) but 'hf_transfer' package is not available in your environment. Try `pip install hf_transfer`.

这里需要安装hf_transfer包

# 打开终端,进入项目根目录(D:\ruanjian\indextts2),运行以下命令:

# 用 uv 安装 hf_transfer,自动放入 .venv 虚拟环境
uv pip install hf_transfer

到这里,就可以正常运行webui.py命令,并成功打开http://127.0.0.1:7860页面了

Logo

中国智能体开发者社区,聚焦智能体与大模型开发,提供前沿资讯、实用工具链、开源项目及行业案例。通过技术沙龙、开发者大赛等活动,促进经验交流与协作,助力开发者快速构建创新智能应用。

更多推荐