Awsl1111ddd commited on
Commit
2b10905
·
verified ·
1 Parent(s): 6bda809

Upload 2 files

Browse files
Files changed (2) hide show
  1. Dockerfile +55 -0
  2. download_support_models.py +18 -0
Dockerfile ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 使用官方 PyTorch 镜像作为基础
2
+ FROM pytorch/pytorch:2.3.1-cuda11.8-cudnn8-runtime
3
+
4
+ # 切换到 root 用户以安装系统依赖
5
+ USER root
6
+
7
+ # 设置环境变量
8
+ ENV PYTHONUNBUFFERED=1 \
9
+ PIP_DISABLE_PIP_VERSION_CHECK=1 \
10
+ PIP_PREFER_BINARY=1 \
11
+ NUMBA_CACHE_DIR=/tmp/numba_cache
12
+
13
+ # 设置工作目录
14
+ WORKDIR /app
15
+
16
+ # 安装系统依赖
17
+ RUN apt-get update && \
18
+ apt-get install -y --no-install-recommends \
19
+ ffmpeg libsox-dev git \
20
+ build-essential cmake ninja-build pkg-config && \
21
+ rm -rf /var/lib/apt/lists/* && \
22
+ mkdir -p /tmp/numba_cache && chmod -R 777 /tmp/numba_cache
23
+
24
+ # [双重保障-步骤1] 预先创建 /nltk_data 目录并赋予 777 权限
25
+ RUN mkdir -p /nltk_data && chmod 777 /nltk_data
26
+
27
+ # 克隆 GPT-SoVITS 仓库
28
+ RUN git clone --depth 1 https://github.com/RVC-Boss/GPT-SoVITS.git /app
29
+
30
+ # 安装 Python 依赖
31
+ RUN pip install --upgrade pip && \
32
+ pip install --no-cache-dir -r /app/requirements.txt && \
33
+ pip install --no-cache-dir --force-reinstall numpy==1.23.5 librosa==0.9.2 numba==0.56.4 && \
34
+ pip install --no-cache-dir fastapi uvicorn soundfile huggingface_hub ffmpeg-python
35
+
36
+ # [双重保障-步骤2 / 关键修复]
37
+ # 在构建镜像时,预先下载好 NLTK 所需的所有数据包,包括新发现的 "averaged_perceptron_tagger_eng"
38
+ 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')"
39
+
40
+ # 预下载依赖模型
41
+ COPY download_support_models.py /app/download_support_models.py
42
+ RUN python /app/download_support_models.py || true
43
+
44
+ # 复制您自己的权重文件和参考音频
45
+ COPY weights/ /app/pretrained_models/shantianliang/
46
+ COPY reference_audio/ /app/reference_audio/
47
+
48
+ # 更改 /app 目录所有权,赋予运行时用户写入权限
49
+ RUN chown -R 1000:1000 /app
50
+
51
+ # 暴露 API 端口
52
+ EXPOSE 7860
53
+
54
+ # 容器启动命令
55
+ CMD ["python", "api_v2.py", "-a", "0.0.0.0", "-p", "7860", "-c", "GPT_SoVITS/configs/tts_infer.yaml"]
download_support_models.py ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from huggingface_hub import snapshot_download
2
+ import os
3
+
4
+ # [关键修改] 将目标文件夹指向程序期望的正确路径
5
+ target = "GPT_SoVITS/pretrained_models"
6
+ os.makedirs(target, exist_ok=True)
7
+
8
+ try:
9
+ snapshot_download(
10
+ repo_id="lj1995/GPT-SoVITS",
11
+ repo_type="model",
12
+ local_dir=target,
13
+ # 注意:这里我们下载全部预训练模型,而不仅仅是sv和chinese
14
+ # allow_patterns=["sv/*", "chinese*"], # 暂时注释掉,确保所有基础模型都被下载
15
+ )
16
+ print("Support models downloaded to ./GPT_SoVITS/pretrained_models")
17
+ except Exception as e:
18
+ print("Skipping support model download:", e)