Skip to content

Commit

Permalink
Merge pull request #83 from Artrajz/dev
Browse files Browse the repository at this point in the history
Change docker base image
  • Loading branch information
Artrajz authored Oct 9, 2023
2 parents 6c6ed2d + 69fe111 commit e0bf06e
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 19 deletions.
16 changes: 7 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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/*
Expand All @@ -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/*

Expand Down
12 changes: 5 additions & 7 deletions Dockerfile_GPU
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
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

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 && \
Expand All @@ -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/*

Expand Down
2 changes: 1 addition & 1 deletion docker-compose-gpu.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 # 挂载配置文件
Expand Down
20 changes: 18 additions & 2 deletions vits/text/japanese.py
Original file line number Diff line number Diff line change
@@ -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(
Expand Down Expand Up @@ -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:
Expand All @@ -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

0 comments on commit e0bf06e

Please sign in to comment.