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

快速启动

确保在执行以下命令时,处于项目根目录下。

  1. WebUI 可视化界面

python examples/web/webui.py
  1. 命令行交互

生成的音频将保存至 ./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

Logo

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

更多推荐