Fix ChatTTS load: pre-download via HF mirror, avoid GitHub timeout.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-06-12 15:16:27 +08:00
parent 1ab1ede1b5
commit aacdffac77
7 changed files with 487 additions and 311 deletions
+19 -4
View File
@@ -365,20 +365,35 @@ pip install -r requirements.txt
`requirements.txt` 安装。首次运行会自动下载 `small` 模型(约 500MB)至 HuggingFace 缓存。
### 6.2 ChatTTS
### 6.2 ChatTTS(必须预下载,勿依赖 GitHub
从 GitHub 源码安装(已在 requirements.txt 中指定):
从 GitHub 源码安装 pip 包(已在 requirements.txt 中指定):
```bash
pip install ChatTTS @ git+https://github.com/2noise/ChatTTS.git
```
首次 `save_fixed_speaker``generate_voice` 时会下载模型权重(数 GB),请确保网络畅通或提前配置 HuggingFace 镜像:
**重要:** 默认 `chat.load()` 会访问 **github.com** 下载 asset,国内服务器常报 `Read timed out (3)`
部署后**必须**执行预下载脚本(走 HuggingFace 镜像):
```bash
export HF_ENDPOINT=https://hf-mirror.com # 可选,国内加速
cd /opt/Trading_Studio
source venv/bin/activate
bash scripts/download_chattts_models.sh
pm2 restart trading_studio
```
模型保存至 `/opt/Trading_Studio/models/ChatTTS`(约 12GB,不入 Git)。
`.env` 可自定义:
```ini
HF_ENDPOINT=https://hf-mirror.com
CHATTTS_MODEL_DIR=/opt/Trading_Studio/models/ChatTTS
```
下载完成后再在 Web UI 点击「锁定音色」。
### 6.3 Gradio
```bash