diff --git a/Dockerfile b/Dockerfile index 982babf..f1b1f95 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,12 +1,14 @@ -FROM python:3.10.11-slim-bullseye +FROM artrajz/pytorch:1.13.1-cpu-py3.10.11-ubuntu22.04 RUN mkdir -p /app WORKDIR /app ENV DEBIAN_FRONTEND=noninteractive + RUN apt-get update && \ - apt-get install -yq build-essential espeak-ng cmake wget && \ + apt-get install -yq build-essential espeak-ng cmake wget ca-certificates tzdata&& \ + update-ca-certificates && \ apt-get clean && \ apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false && \ rm -rf /var/lib/apt/lists/* @@ -16,20 +18,16 @@ RUN wget https://github.com/jemalloc/jemalloc/releases/download/5.3.0/jemalloc-5 tar -xvf jemalloc-5.3.0.tar.bz2 && \ cd jemalloc-5.3.0 && \ ./configure && \ - make && \ + make -j$(nproc) && \ make install && \ cd .. && \ rm -rf jemalloc-5.3.0* && \ - ldconfig + ldconfig ENV LD_PRELOAD=/usr/local/lib/libjemalloc.so -RUN pip install torch --index-url https://download.pytorch.org/whl/cpu --no-cache-dir - COPY requirements.txt /app/ -RUN pip install --upgrade pip && \ - pip install pyopenjtalk==0.3.2 -i https://pypi.artrajz.cn/simple --no-cache-dir && \ - pip install gunicorn --no-cache-dir && \ +RUN pip install gunicorn --no-cache-dir && \ pip install -r requirements.txt --no-cache-dir&& \ rm -rf /root/.cache/pip/* diff --git a/Dockerfile_GPU b/Dockerfile_GPU index be93765..160a823 100644 --- a/Dockerfile_GPU +++ b/Dockerfile_GPU @@ -1,4 +1,4 @@ -FROM cnstark/pytorch:2.0.1-py3.10.11-cuda11.8.0-ubuntu22.04 +FROM artrajz/pytorch:1.13.1-cu117-py3.10.11-ubuntu22.04 RUN mkdir -p /app WORKDIR /app @@ -6,7 +6,7 @@ WORKDIR /app ENV DEBIAN_FRONTEND=noninteractive RUN apt-get update && \ - apt-get install -yq build-essential espeak-ng cmake wget ca-certificates && \ + apt-get install -yq build-essential espeak-ng cmake wget ca-certificates tzdata&& \ update-ca-certificates && \ apt-get clean && \ apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false && \ @@ -18,18 +18,16 @@ RUN wget https://github.com/jemalloc/jemalloc/releases/download/5.3.0/jemalloc-5 tar -xvf jemalloc-5.3.0.tar.bz2 && \ cd jemalloc-5.3.0 && \ ./configure && \ - make && \ + make -j$(nproc) && \ make install && \ cd .. && \ rm -rf jemalloc-5.3.0* && \ - ldconfig + ldconfig ENV LD_PRELOAD=/usr/local/lib/libjemalloc.so COPY requirements.txt /app/ -RUN pip install --upgrade pip && \ - pip install pyopenjtalk==0.3.2 fasttext -i https://pypi.artrajz.cn/simple --no-cache-dir && \ - pip install gunicorn --no-cache-dir && \ +RUN pip install gunicorn --no-cache-dir && \ pip install -r requirements.txt --no-cache-dir&& \ rm -rf /root/.cache/pip/* diff --git a/docker-compose-gpu.yaml b/docker-compose-gpu.yaml index d9b7cfd..27680c0 100644 --- a/docker-compose-gpu.yaml +++ b/docker-compose-gpu.yaml @@ -8,7 +8,7 @@ services: - 23456:23456 environment: LANG: 'C.UTF-8' - #TZ: Asia/Shanghai #timezone + TZ: Asia/Shanghai #timezone volumes: - ./Model:/app/Model # 挂载模型文件夹 - ./config.py:/app/config.py # 挂载配置文件 diff --git a/vits/text/japanese.py b/vits/text/japanese.py index 375e4d5..f5fe772 100644 --- a/vits/text/japanese.py +++ b/vits/text/japanese.py @@ -1,7 +1,23 @@ +import os import re from unidecode import unidecode import pyopenjtalk +from config import ABS_PATH +from utils.download import download_and_verify + +URLS = [ + "https://github.com/r9y9/open_jtalk/releases/download/v1.11.1/open_jtalk_dic_utf_8-1.11.tar.gz", + "https://ghproxy.com/https://github.com/r9y9/open_jtalk/releases/download/v1.11.1/open_jtalk_dic_utf_8-1.11.tar.gz", +] +install_path = os.path.dirname(pyopenjtalk.__file__) +dict_path = os.path.join(install_path, "open_jtalk_dic_utf_8-1.11", "char.bin") +TARGET_PATH = os.path.join(ABS_PATH, "open_jtalk_dic_utf_8-1.11.tar.gz") +EXTRACT_DESTINATION = os.path.join(install_path, "") +EXPECTED_MD5 = None + +if not os.path.exists(dict_path): + success, message = download_and_verify(URLS, TARGET_PATH, EXPECTED_MD5, EXTRACT_DESTINATION) # Regular expression matching Japanese without punctuation marks: _japanese_characters = re.compile( @@ -127,7 +143,7 @@ def get_real_hatsuon(text): def japanese_to_ipa(text): text = japanese_to_romaji_with_accent(text).replace('...', '…') text = re.sub( - r'([aiueo])\1+', lambda x: x.group(0)[0]+'ː'*(len(x.group(0))-1), text) + r'([aiueo])\1+', lambda x: x.group(0)[0] + 'ː' * (len(x.group(0)) - 1), text) text = get_real_sokuon(text) text = get_real_hatsuon(text) for regex, replacement in _romaji_to_ipa: @@ -148,6 +164,6 @@ def japanese_to_ipa3(text): text = japanese_to_ipa2(text).replace('n^', 'ȵ').replace( 'ʃ', 'ɕ').replace('*', '\u0325').replace('#', '\u031a') text = re.sub( - r'([aiɯeo])\1+', lambda x: x.group(0)[0]+'ː'*(len(x.group(0))-1), text) + r'([aiɯeo])\1+', lambda x: x.group(0)[0] + 'ː' * (len(x.group(0)) - 1), text) text = re.sub(r'((?:^|\s)(?:ts|tɕ|[kpt]))', r'\1ʰ', text) return text