python 版本3.10
python --version
#windows
C:\Users\Administrator\AppData\Local\Programs\Python
C:\Users\Administrator>python --version
Python 3.10.0
#安裝的時候記得安裝vc++
直接安裝
pip install --upgrade -r requirements.txt
快速啓動
確保在執行以下命令時,處於項目根目錄下。
- WebUI 可視化界面
python examples/web/webui.py
- 命令行交互
生成的音頻將保存至
./output_audio_n.mp3
python examples/cmd/run.py "Your text 1." "Your text 2."
Miniconda安裝
#安裝教程
https://www.anaconda.com/docs/getting-started/miniconda/install#windows-command-prompt
#安裝步驟 PowerShell執行
# 1. 切換到你想下載的目錄
cd C:\Users\Administrator\Downloads
# 2. 下載 Miniconda 安裝程序(注意完整文件名)
curl https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe -o .\miniconda.exe
# 3. 確認文件存在
Get-ChildItem .\miniconda.exe
# 4. 靜默安裝
Start-Process -FilePath ".\miniconda.exe" -ArgumentList "/S /D=C:\Miniconda3" -Wait
# 5. 刪除安裝程序
Remove-Item .\miniconda.exe
#設置系統path
C:\Miniconda3
C:\Miniconda3\Scripts
C:\Miniconda3\Library\bin
#查看版本conda
conda --version
conda
#先創建 Python 3.14 環境(只安裝 Python)
conda create -n py314 python=3.14 -y
#激活環境
conda activate py314
#嘗試安裝 Pynini
conda install -c conda-forge pynini
# 配置清華鏡像
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2/
conda config --set show_channel_urls yes
安裝工具
pip一定要有
#更新
python.exe -m pip install --upgrade pip
pip install nemo_text_processing
pip install WeTextProcessing
Docker 需要服務器支持顯卡和gpu 很麻煩
/home/
git clone https://github.com/2noise/ChatTTS
cd ChatTTS
#最終目錄
/home/ChatTTS
vim /home/ChatTTS/docker-compose.yml
version: "3.9"
services:
chattts:
build: .
container_name: chattts
restart: unless-stopped
ports:
- "8080:8080"
volumes:
- .:/app
deploy:
resources:
reservations:
devices:
- driver: nvidia
count: all
capabilities: [gpu]
environment:
- NVIDIA_VISIBLE_DEVICES=all
- PYTHONUNBUFFERED=1
- HF_ENDPOINT=https://huggingface.co
vim Dockerfile
# ===============================
# ✅ ChatTTS 完整環境構建 Dockerfile
# 支持 GPU / CPU 自動兼容
# ===============================
# 基於官方 PyTorch 鏡像 (CUDA 12.1 + Python 3.10)
FROM pytorch/pytorch:2.3.1-cuda12.1-cudnn8-runtime
# 設置工作目錄
WORKDIR /app
# 複製本地 ChatTTS 源碼
COPY . .
# 更新系統包並安裝構建依賴和音頻支持庫
RUN apt-get update && apt-get install -y \
build-essential \
gcc \
g++ \
make \
cmake \
git \
curl \
wget \
unzip \
ffmpeg \
libsndfile1 \
libffi-dev \
libssl-dev \
python3-dev \
&& rm -rf /var/lib/apt/lists/*
# 更新 pip 並安裝 Python 依賴
RUN pip install --no-cache-dir -U pip setuptools wheel
# 優化科學計算依賴(防止 torchtext 等衝突)
RUN pip install --no-cache-dir numpy scipy torch torchvision torchaudio
# 安裝 ChatTTS 相關依賴
COPY requirements.txt /app/requirements.txt
RUN pip install --no-cache-dir -r requirements.txt || true
# 手動安裝容易出錯的依賴(確保構建成功)
RUN pip install --no-cache-dir cdifflib WeTextProcessing nemo_text_processing
# 可選:安裝 Web UI 所需組件(如 gradio / flask)
RUN pip install --no-cache-dir gradio fastapi uvicorn
# 環境變量(防止 huggingface 下載卡頓)
ENV HF_ENDPOINT=https://huggingface.co \
PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1
# 公開端口
EXPOSE 8080
# 啓動命令(根據項目啓動文件調整)
# 如果 ChatTTS 有 webui.py 或 app.py,則修改為對應文件
CMD ["python", "app.py"]
啓動
#啓動
docker-compose build --no-cache
docker-compose up -d
#日誌觀察
docker logs -f 254efb26fd9f