1
File size: 2,869 Bytes
71907f3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
116361e
71907f3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
116361e
 
71907f3
 
116361e
 
 
 
 
 
71907f3
116361e
71907f3
 
 
116361e
71907f3
 
 
 
 
 
 
 
116361e
71907f3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# 使用官方 PyTorch 基础镜像
FROM pytorch/pytorch:2.3.1-cuda11.8-cudnn8-runtime

# 切换到 root 用户以进行系统级安装
USER root

# 设置环境变量
ENV PYTHONUNBUFFERED=1 \
    PIP_DISABLE_PIP_VERSION_CHECK=1 \
    PIP_PREFER_BINARY=1 \
    NUMBA_CACHE_DIR=/tmp/numba_cache

# 设置工作目录
WORKDIR /app

# 安装系统依赖 (已包含 curl 和 wget)
RUN apt-get update && \
    apt-get install -y --no-install-recommends \
      wget curl ffmpeg libsox-dev git \
      build-essential cmake ninja-build pkg-config && \
    rm -rf /var/lib/apt/lists/* && \
    mkdir -p /tmp/numba_cache && chmod -R 777 /tmp/numba_cache

# 创建并授权 NLTK 数据目录
RUN mkdir -p /nltk_data && chmod 777 /nltk_data

# 克隆 GPT-SoVITS 仓库
RUN git clone --depth 1 https://github.com/RVC-Boss/GPT-SoVITS.git /app

# 安装 Python 依赖
RUN pip install --upgrade pip && \
    pip install --no-cache-dir -r /app/requirements.txt && \
    pip install --no-cache-dir --force-reinstall numpy==1.23.5 librosa==0.9.2 numba==0.56.4 && \
    pip install --no-cache-dir fastapi uvicorn soundfile huggingface_hub ffmpeg-python

# 预下载 NLTK 数据包
RUN python -c "import nltk; nltk.download('punkt', quiet=True, download_dir='/nltk_data'); nltk.download('averaged_perceptron_tagger', quiet=True, download_dir='/nltk_data'); nltk.download('averaged_perceptron_tagger_eng', quiet=True, download_dir='/nltk_data')"

# 预下载官方支持模型
COPY download_support_models.py /app/download_support_models.py
RUN python /app/download_support_models.py || true

# --- 从 Hugging Face Spaces 下载您自己的模型权重 ---
ARG GPT_URL="https://huggingface.co/spaces/snsbhg/1111/resolve/main/weights/shantianliang_proplus_e32.ckpt"
ARG SOVITS_URL="https://huggingface.co/spaces/snsbhg/1111/resolve/main/weights/shantianliang_proplus_e8_s192.pth"
RUN mkdir -p /app/pretrained_models/shantianliang && \
    wget -nv "$GPT_URL" -O /app/pretrained_models/shantianliang/shantianliang_proplus_e32.ckpt && \
    wget -nv "$SOVITS_URL" -O /app/pretrained_models/shantianliang/shantianliang_proplus_e8_s192.pth

# --- [修改] 将本地复制改为从URL下载参考音频 ---
RUN echo "--- Downloading reference audio file ---" && \
    mkdir -p /app/reference_audio && \
    wget -nv "https://huggingface.co/spaces/Awsl1111ddd/cialloapi/raw/main/reference_audio/ref_shantianliang_1.wav" \
         -O /app/reference_audio/ref_shantianliang_1.wav && \
    echo "--- Reference audio downloaded successfully ---"

# 复制监控和启动脚本
COPY monitor_and_upload.sh /app/monitor_and_upload.sh
COPY start.sh /app/start.sh

# 赋予脚本执行权限
RUN chmod +x /app/start.sh /app/monitor_and_upload.sh

# 更改 /app 目录所有权
RUN chown -R 1000:1000 /app

# 暴露 API 端口
EXPOSE 7860

# 使用 start.sh 脚本作为启动命令
CMD ["/app/start.sh"]