deploy docker

This commit is contained in:
2025-04-10 09:45:41 +00:00
parent 1955f05876
commit b3fc313a15
46 changed files with 1024 additions and 169 deletions
+15
View File
@@ -0,0 +1,15 @@
# 排除 TTS 目录
TTS/
# 排除 sample 目录
sample/
# 排除其他不需要的文件
__pycache__/
*.pyc
*.pyo
*.pyd
.Python
env/
venv/
.env
*.log
+3 -3
View File
@@ -25,13 +25,13 @@ REDIS_SESSION_DB_KO=50
# GPT-SoVITS 配置
GPT_MODEL_PATH=GPT_SoVITS/pretrained_models/gsv-v2final-pretrained/s1bert25hz-5kh-longer-epoch=12-step=369668.ckpt
SOVITS_MODEL_PATH=GPT_SoVITS/pretrained_models/gsv-v2final-pretrained/s2G2333k.pth
GPT_MODEL_PATH=TTS/GPT_SoVITS/pretrained_models/gsv-v2final-pretrained/s1bert25hz-5kh-longer-epoch=12-step=369668.ckpt
SOVITS_MODEL_PATH=TTS/GPT_SoVITS/pretrained_models/gsv-v2final-pretrained/s2G2333k.pth
REF_AUDIO_PATH=sample/woman.wav
REF_TEXT_PATH=sample/woman.txt
REF_LANGUAGE=中文
TARGET_LANGUAGE=多语种混合
OUTPUT_PATH=/obscura/task/audio_files
OUTPUT_PATH=${OBSCURA_AUDIO_PATH:-/obscura/task/audio_files}
# VOICE_CONFIGS
GIRL_REF_AUDIO=sample/gril.wav
+82
View File
@@ -0,0 +1,82 @@
# 构建阶段
FROM swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/nvidia/cuda:12.4.1-cudnn-runtime-ubuntu22.04 AS builder
ENV DEBIAN_FRONTEND=noninteractive
ENV TZ=Asia/Shanghai
# 配置apt源为清华源
RUN sed -i 's/archive.ubuntu.com/mirrors.tuna.tsinghua.edu.cn/g' /etc/apt/sources.list && \
sed -i 's/security.ubuntu.com/mirrors.tuna.tsinghua.edu.cn/g' /etc/apt/sources.list
RUN apt-get update && apt-get install -y \
software-properties-common \
curl \
build-essential \
&& add-apt-repository ppa:deadsnakes/ppa \
&& apt-get update \
&& apt-get install -y python3.11 python3.11-dev python3.11-distutils \
&& curl -sS https://bootstrap.pypa.io/get-pip.py -o get-pip.py \
&& python3.11 get-pip.py -i https://pypi.tuna.tsinghua.edu.cn/simple \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# 设置Python 3.11为默认版本
RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.11 1 && \
update-alternatives --set python3 /usr/bin/python3.11
WORKDIR /api_chat
# 配置pip源为清华源
RUN pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
# 安装依赖
COPY requirements.txt .
RUN python3 -m pip install --no-cache-dir -r requirements.txt
# 修复LangSegment库
RUN sed -i 's/from .LangSegment import LangSegment,getTexts,classify,getCounts,printList,setLangfilters,getLangfilters,setfilters,getfilters/from .LangSegment import LangSegment,getTexts,classify,getCounts,printList,setfilters,getfilters/' /usr/local/lib/python3.11/dist-packages/LangSegment/__init__.py
# 最终阶段
FROM swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/nvidia/cuda:12.4.1-cudnn-runtime-ubuntu22.04
ENV DEBIAN_FRONTEND=noninteractive
ENV TZ=Asia/Shanghai
# 添加路径映射环境变量
ENV OBSCURA_BASE_PATH=/obscura
ENV OBSCURA_AUDIO_PATH=/obscura/task/audio_files
# 配置apt源为清华源
RUN sed -i 's/archive.ubuntu.com/mirrors.tuna.tsinghua.edu.cn/g' /etc/apt/sources.list && \
sed -i 's/security.ubuntu.com/mirrors.tuna.tsinghua.edu.cn/g' /etc/apt/sources.list
RUN apt-get update && apt-get install -y \
ffmpeg \
libgl1-mesa-glx \
python3.11 \
python3.11-distutils \
libglib2.0-0 \
libsm6 \
libxext6 \
libxrender-dev \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# 设置Python 3.11为默认版本
RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.11 1 && \
update-alternatives --set python3 /usr/bin/python3.11
WORKDIR /api_chat
# 从构建阶段复制Python包
COPY --from=builder /usr/local/lib/python3.11/dist-packages /usr/local/lib/python3.11/dist-packages
# 创建必要的目录(这些目录将被挂载)
RUN mkdir -p ${OBSCURA_AUDIO_PATH} /sample /TTS
# 复制应用代码,包括TTS目录
COPY . .
# 启动服务并保持容器运行
CMD ["sh", "-c", "bash start.sh && tail -f /dev/null"]
Binary file not shown.
View File
View File
View File
+1
View File
@@ -0,0 +1 @@
2699902
+1
View File
@@ -0,0 +1 @@
2700008
+1
View File
@@ -0,0 +1 @@
2699821
+129
View File
@@ -0,0 +1,129 @@
async_timeout>=4.0.0
aiofiles==23.2.1
aiohappyeyeballs==2.6.1
aiohttp==3.11.16
aiosignal==1.3.2
annotated-types==0.7.0
anyio==4.9.0
attrs==25.3.0
audioread==3.0.1
av==14.3.0
certifi==2025.1.31
cffi==1.17.1
charset-normalizer==3.4.1
click==8.1.8
cn2an==0.5.23
coloredlogs==15.0.1
contourpy==1.3.1
cycler==0.12.1
decorator==5.2.1
decord==0.6.0
einops==0.8.1
fastapi==0.115.12
ffmpeg-python==0.2.0
ffmpy==0.5.0
filelock==3.18.0
flatbuffers==25.2.10
fonttools==4.56.0
frozenlist==1.5.0
fsspec==2025.3.2
future==1.0.0
g2p-en==2.1.0
gradio==5.23.3
gradio_client==1.8.0
h11==0.14.0
httpcore==1.0.7
httpx==0.28.1
huggingface-hub==0.30.1
humanfriendly==10.0
idna==3.10
inflect==7.5.0
jieba_fast==0.53
Jinja2==3.1.6
joblib==1.4.2
kafka-python==2.1.4
kiwisolver==1.4.8
LangSegment==0.2.0
lazy_loader==0.4
librosa==0.11.0
lightning-utilities==0.14.2
llvmlite==0.44.0
markdown-it-py==3.0.0
MarkupSafe==3.0.2
matplotlib==3.10.1
mdurl==0.1.2
more-itertools==10.6.0
mpmath==1.3.0
msgpack==1.1.0
multidict==6.2.0
networkx==3.4.2
nltk==3.9.1
numba==0.61.0
numpy==1.24.3
onnxruntime==1.21.0
onnxruntime-gpu==1.21.0
openai-whisper==20240930
opencc-python-reimplemented==0.1.7
orjson==3.10.16
opencv-python
packaging==24.2
pandas==2.2.3
pillow==11.1.0
platformdirs==4.3.7
pooch==1.8.2
propcache==0.3.1
protobuf==6.30.2
py3langid==0.2.2
pycparser==2.22
pydantic==2.11.1
pydantic_core==2.33.0
pydub==0.25.1
pyee==13.0.0
Pygments==2.19.1
pyparsing==3.2.3
pypinyin==0.54.0
python-dateutil==2.9.0.post0
python-dotenv==1.1.0
python-multipart==0.0.20
pytorch-lightning==2.5.1
pytz==2025.2
PyYAML==6.0.2
qwen-vl-utils==0.0.10
redis==5.2.1
regex==2024.11.6
requests==2.32.3
rich==14.0.0
ruff==0.11.2
safehttpx==0.1.6
safetensors==0.5.3
scikit-learn==1.6.1
scipy==1.15.2
semantic-version==2.10.0
shellingham==1.5.4
six==1.17.0
sniffio==1.3.1
soundfile==0.13.1
soxr==0.5.0.post1
starlette==0.46.1
sympy==1.13.3
threadpoolctl==3.6.0
tiktoken==0.9.0
tokenizers==0.21.1
tomlkit==0.13.2
torch==2.1.0
torchmetrics==1.7.0
torchvision==0.16.0
tqdm==4.67.1
transformers==4.50.3
triton==2.1.0
typeguard==4.4.2
typer==0.15.2
typing-inspection==0.4.0
typing_extensions==4.13.0
tzdata==2025.2
urllib3==2.3.0
utils==1.0.2
uvicorn==0.34.0
websockets==15.0.1
wordsegment==1.3.1
yarl==1.18.3
+36
View File
@@ -0,0 +1,36 @@
#!/bin/bash
# 设置工作目录
cd "$(dirname "$0")"
# 创建日志目录
mkdir -p logs
# 创建存放PID文件的目录
mkdir -p pids
# 定义要启动的服务
services=(
"tts.py"
"asr.py"
"chat.py"
)
# 启动所有服务
for service in "${services[@]}"; do
echo "启动 $service..."
# 直接在后台运行Python服务
python3 "$service" > "logs/${service%.py}.log" 2>&1 &
# 记录进程ID
echo $! > "pids/${service%.py}.pid"
# 等待几秒钟,确保服务正常启动
sleep 2
done
echo "所有服务已启动,请检查logs目录下的日志文件"
echo "使用 'cat logs/*.log' 查看日志"
# 保持容器运行
while true; do
sleep 1
done
View File
+2 -2
View File
@@ -5,8 +5,8 @@ import hashlib
import json
import traceback
from kafka import KafkaConsumer
from tools.i18n.i18n import I18nAuto
from GPT_SoVITS.inference_webui import change_gpt_weights, change_sovits_weights, get_tts_wav
from TTS.tools.i18n.i18n import I18nAuto
from TTS.GPT_SoVITS.inference_webui import change_gpt_weights, change_sovits_weights, get_tts_wav
from dotenv import load_dotenv
import torch
+1 -1
View File
@@ -1 +1 @@
{"GPT": {"v1": "GPT_SoVITS/pretrained_models/s1bert25hz-2kh-longer-epoch=68e-step=50232.ckpt", "v2": "GPT_SoVITS/pretrained_models/gsv-v2final-pretrained/s1bert25hz-5kh-longer-epoch=12-step=369668.ckpt"}, "SoVITS": {"v1": "GPT_SoVITS/pretrained_models/s2G488k.pth", "v2": "GPT_SoVITS/pretrained_models/gsv-v2final-pretrained/s2G2333k.pth"}}
{"GPT": {"v1": "TTS/GPT_SoVITS/pretrained_models/s1bert25hz-2kh-longer-epoch=68e-step=50232.ckpt", "v2": "TTS/GPT_SoVITS/pretrained_models/gsv-v2final-pretrained/s1bert25hz-5kh-longer-epoch=12-step=369668.ckpt"}, "SoVITS": {"v1": "TTS/GPT_SoVITS/pretrained_models/s2G488k.pth", "v2": "TTS/GPT_SoVITS/pretrained_models/gsv-v2final-pretrained/s2G2333k.pth"}}