diff --git a/.dockerignore b/.dockerignore index 3a08484..9414382 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,8 +1 @@ Dockerfile -.venv -checkpoints/ -metadata/ -wavs/ -*.wav -*.ckpt -*.csv \ No newline at end of file diff --git a/.gitignore b/.gitignore index 489770b..e43b0f9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,12 +1 @@ -.venv -*.wav -*.ckpt -*.csv -*.onnx -*.json -*.yaml -*.yml -*events* -.venv -.mypy_cache -.drafts/ \ No newline at end of file +.DS_Store diff --git a/Dockerfile b/Dockerfile index 9acf1cb..3b4ae8d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,34 +1,39 @@ -FROM nvidia/cuda:12.9.1-cudnn-devel-ubuntu24.04 +FROM nvidia/cuda:12.1.1-cudnn8-runtime-ubuntu22.04 ENV DEBIAN_FRONTEND=noninteractive \ - LANG=C.UTF-8 \ - LC_ALL=C.UTF-8 \ - PATH="/usr/local/bin:/root/.local/bin:/root/bin:/piper/.venv/bin:${PATH}" + PIP_DISABLE_PIP_VERSION_CHECK=1 \ + PYTHONUNBUFFERED=1 \ + VENV_PATH=/opt/venv -RUN apt-get update && apt upgrade -y && apt-get install -y --no-install-recommends \ - bash coreutils vim nano \ - git curl wget ca-certificates gnupg \ - build-essential pkg-config ninja-build cmake \ - python3 python3-pip python3-venv python3-dev \ - ffmpeg espeak-ng \ - && rm -rf /var/lib/apt/lists/* - -COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv -RUN chmod +x /usr/local/bin/uv +ENV PATH="${VENV_PATH}/bin:${PATH}" WORKDIR /piper -RUN git clone --depth 1 --branch v1.3.0 https://github.com/OHF-voice/piper1-gpl.git . -# RUN if ! [ -d wavs ]; then mkdir wavs; fi && if ! [ -d metadata ]; then mkdir metadata; fi && if ! [ -d checkpoints ]; then mkdir checkpoints; fi && if ! [ -d lightning_logs ]; then mkdir lightning_logs; fi && if ! [ -d cache ]; then mkdir cache; fi -RUN uv python install 3.13 && uv python pin 3.13 && uv venv .venv --python 3.13 +RUN apt-get update \ + && apt-get install -y --no-install-recommends \ + build-essential \ + cmake \ + espeak-ng \ + git \ + ninja-build \ + pkg-config \ + python3 \ + python3-dev \ + python3-venv \ + && rm -rf /var/lib/apt/lists/* -RUN uv pip install -e .[train] torch==2.5.1 lightning==2.1.0 numpy "ml_dtypes>=0.5.0" scikit-build \ - --index https://download.pytorch.org/whl/cu124 \ - --index https://pypi.org/simple \ - --index-strategy=unsafe-best-match \ - --compile-bytecode +RUN git clone --depth 1 https://github.com/OHF-voice/piper1-gpl.git . -RUN uv run python3 setup.py build_ext --inplace -RUN . .venv/bin/activate && ./build_monotonic_align.sh +RUN python3 -m venv ${VENV_PATH} -ENV UV_OFFLINE=1 +RUN pip install --upgrade pip wheel setuptools \ + && pip install --no-cache-dir cmake scikit-build \ + && pip install --no-cache-dir -e '.[train]' + +RUN ./build_monotonic_align.sh \ + && python3 setup.py build_ext --inplace + +COPY entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh + +ENTRYPOINT ["/entrypoint.sh"] diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..7deec3f --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +set -e + +CKPT_DIR="/piper/lightning_logs" +CKPT="" + +if compgen -G "${CKPT_DIR}/version_*/checkpoints/*.ckpt" > /dev/null; then + CKPT=$(ls -t ${CKPT_DIR}/version_*/checkpoints/*.ckpt | head -n1) + RESUME_ARG="--trainer.resume_from_checkpoint $CKPT" + + echo "Resuming: $CKPT" +fi + +exec python3 -m piper.train fit \ + --data.voice_name pt_BR-well \ + --data.espeak_voice pt-br \ + --data.audio_dir /data/wav/ \ + --data.batch_size 16 \ + --data.cache_dir /data/.cache/ \ + --data.config_path /data/config.json \ + --data.csv_path /data/metadata.csv \ + --model.sample_rate 22050 \ + --trainer.check_val_every_n_epoch 1 \ + --trainer.max_epochs 10000 \ + $RESUME_ARG diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 636fe1c..0000000 --- a/requirements.txt +++ /dev/null @@ -1,90 +0,0 @@ -absl-py==2.3.1 -aiohappyeyeballs==2.6.1 -aiohttp==3.13.2 -aiosignal==1.4.0 -attrs==25.4.0 -audioop-lts==0.2.2 -audioread==3.1.0 -certifi==2025.11.12 -cffi==2.0.0 -charset-normalizer==3.4.4 -coloredlogs==15.0.1 -cython==3.2.1 -decorator==5.2.1 -distro==1.9.0 -docstring-parser==0.17.0 -filelock==3.20.0 -flatbuffers==25.9.23 -frozenlist==1.8.0 -fsspec==2024.12.0 -grpcio==1.76.0 -humanfriendly==10.0 -idna==3.11 -importlib-resources==6.5.2 -jinja2==3.1.6 -joblib==1.5.2 -jsonargparse==4.43.0 -lazy-loader==0.4 -librosa==0.11.0 -lightning==2.1.0 -lightning-utilities==0.15.2 -llvmlite==0.45.1 -markdown==3.10 -markupsafe==3.0.3 -ml-dtypes==0.5.3 -mpmath==1.3.0 -msgpack==1.1.2 -multidict==6.7.0 -networkx==3.5 -numba==0.62.1 -numpy==2.3.4 -nvidia-cublas-cu12==12.4.5.8 -nvidia-cuda-cupti-cu12==12.4.127 -nvidia-cuda-nvrtc-cu12==12.4.127 -nvidia-cuda-runtime-cu12==12.4.127 -nvidia-cudnn-cu12==9.1.0.70 -nvidia-cufft-cu12==11.2.1.3 -nvidia-curand-cu12==10.3.5.147 -nvidia-cusolver-cu12==11.6.1.9 -nvidia-cusparse-cu12==12.3.1.170 -nvidia-nccl-cu12==2.21.5 -nvidia-nvjitlink-cu12==12.4.127 -nvidia-nvtx-cu12==12.4.127 -onnx==1.19.1 -onnxruntime==1.23.2 -packaging==24.2 -pathvalidate==3.3.1 -pillow==12.0.0 -piper-tts==1.3.0 -platformdirs==4.5.0 -pooch==1.8.2 -propcache==0.4.1 -protobuf==6.33.1 -pycparser==2.23 -pysilero-vad==2.1.1 -pytorch-lightning==2.5.6 -pyyaml==6.0.3 -requests==2.32.5 -scikit-build==0.18.1 -scikit-learn==1.7.2 -scipy==1.16.3 -setuptools==80.9.0 -soundfile==0.13.1 -soxr==1.0.0 -standard-aifc==3.13.0 -standard-chunk==3.13.0 -standard-sunau==3.13.0 -sympy==1.13.1 -tensorboard==2.20.0 -tensorboard-data-server==0.7.2 -tensorboardx==2.6.4 -threadpoolctl==3.6.0 -torch==2.5.1+cu124 -torchmetrics==1.8.2 -tqdm==4.67.1 -typeshed-client==2.8.2 -typing-extensions==4.15.0 -urllib3==2.5.0 -werkzeug==3.1.3 -wheel==0.45.1 -yarl==1.22.0 \ No newline at end of file