FROM python:3.10-slim WORKDIR /app # 安装 FFmpeg 和基础编译工具 RUN apt-get update && apt-get install -y \ git ffmpeg build-essential cmake libmecab-dev mecab-ipadic-utf8 \ && rm -rf /var/lib/apt/lists/* # 安装 genie_tts 的所有依赖(使用本地源码,不安装 genie_tts 包) RUN pip install --no-cache-dir \ onnx onnxruntime==1.22.1 tokenizers numpy soundfile soxr pyyaml \ sounddevice pydantic "huggingface_hub[hf_xet]" \ fastapi "uvicorn[standard]" python-multipart \ pyopenjtalk-plus \ nltk \ pypinyin g2pM jieba_fast # 复制所有文件(包括本地 genie_tts 源码) COPY . /app # 预下载 GenieData 资源(避免每次启动都下载) RUN python -c "from huggingface_hub import snapshot_download; snapshot_download(repo_id='High-Logic/Genie', allow_patterns=['GenieData/*'], local_dir='/app', local_dir_use_symlinks=False)" # 预下载 mzm 模型到 models/mzm 目录 RUN python -c "from huggingface_hub import snapshot_download; snapshot_download(repo_id='simler/mzm-model', local_dir='/app/models/mzm', local_dir_use_symlinks=False)" # 镜像权限处理 RUN chmod -R 777 /app EXPOSE 7860 # 使用直接启动模式 CMD ["python", "app.py"]