diff --git a/.vscode/settings.json b/.vscode/settings.json index 89a552b..bf99ca8 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -5,10 +5,12 @@ "cudnn", "cufft", "curand", + "espeak", "manylinux", "nvrtc", "onnxruntime", "phonemize", + "rhasspy", "setuptools", "slackr", "venv", diff --git a/Dockerfile b/Dockerfile index 4a18c33..bca1952 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,8 +4,9 @@ WORKDIR /usr/src ARG TARGETARCH=amd64 ARG TARGETVARIANT= -ARG WYOMING_PIPER_VERSION='1.4.0' -ARG PIPER_RELEASE='1.2.0' +ARG WYOMING_PIPER_VERSION="1.4.0" +ARG PIPER_RELEASE="1.2.0" +ARG PIPER_URL="https://github.com/rhasspy/piper/releases/download/v${PIPER_RELEASE}/piper_${TARGETARCH}${TARGETVARIANT}.tar.gz" ENV DEBIAN_FRONTEND=noninteractive @@ -45,32 +46,26 @@ RUN \ onnxruntime-gpu \ &&\ \ - /app/bin/python3 -m pip install --no-cache-dir\ + /app/bin/python3 -m pip install --force-reinstall --no-cache-dir\ "wyoming-piper==${WYOMING_PIPER_VERSION}"\ &&\ \ - wget \ - "https://github.com/rhasspy/piper/releases/download/v${PIPER_RELEASE}/piper_${TARGETARCH}${TARGETVARIANT}.tar.gz" -O -|tar -zxvf - -C /usr/share + wget "${PIPER_URL}" -O -|tar -zxvf - -C /app - # pip3 install --no-cache-dir --force-reinstall --no-deps\ - # piper_phonemize-1.1.0-py3-none-any.whl &&\ - # \ - # "wyoming-piper @ https://github.com/rhasspy/wyoming-piper/archive/refs/tags/v${WYOMING_PIPER_VERSION}.tar.gz" - # wget https://github.com/rhasspy/piper-phonemize/releases/download/v1.1.0/piper_phonemize-1.1.0-cp310-cp310-manylinux_2_28_x86_64.whl &&\ - # mv piper_phonemize-1.1.0-cp310-cp310-manylinux_2_28_x86_64.whl piper_phonemize-1.1.0-py3-none-any.whl &&\ - # rm -r piper_phonemize-1.1.0-py3-none-any.whl &&\ # Patch to enable CUDA arguments for piper -COPY patch/wyoming-piper_cuda.patch /tmp/ +COPY patch/* /tmp/ RUN \ cd /app/lib/python3.10/site-packages/wyoming_piper/;\ - patch -p0 --forward < /tmp/wyoming-piper_cuda.patch || true + patch -p0 --forward < /tmp/__main__.py.diff;\ + patch -p0 --forward < /tmp/process.py.diff;\ + patch -p0 --forward < /tmp/handler.py.diff || true # Clean up RUN \ rm -rf /root/.cache/pip /var/lib/apt/lists/* /tmp/* -COPY tests/* /app/tests/ +# COPY tests/* /app/tests/ WORKDIR /app COPY run.sh /app/ diff --git a/patch/__main__.diff b/patch/__main__.diff new file mode 100644 index 0000000..3a3ff45 --- /dev/null +++ b/patch/__main__.diff @@ -0,0 +1,16 @@ +--- __main__.py 2025-01-04 17:48:27.645862671 +0000 ++++ __main__.py.patched 2025-01-04 17:51:50.193357609 +0000 +@@ -66,6 +66,15 @@ + help="Download latest voices.json during startup", + ) + # ++ parser.add_argument( ++ "--cuda", ++ action="store_true", ++ help="Use GPU" ++ ) ++ parser.add_argument( ++ "--espeak-data-dir", ++ help="Path to espeak-ng data directory" ++ ) ++ diff --git a/patch/handler.diff b/patch/handler.diff new file mode 100644 index 0000000..df4ebb2 --- /dev/null +++ b/patch/handler.diff @@ -0,0 +1,10 @@ +--- handler.py 2025-01-04 19:50:00.000000000 +0000 ++++ handler.py.patched 2025-01-04 20:58:52.201781636 +0000 +@@ -88,7 +88,7 @@ + + _LOGGER.debug("input: %s", input_obj) + piper_proc.proc.stdin.write( +- (json.dumps(input_obj, ensure_ascii=False) + "\n").encode() ++ f{text}"\n").encode() + ) + await piper_proc.proc.stdin.drain() diff --git a/patch/process.diff b/patch/process.diff new file mode 100644 index 0000000..a0f7bda --- /dev/null +++ b/patch/process.diff @@ -0,0 +1,23 @@ +--- process.py 2025-01-04 19:50:00.000000000 +0000 ++++ process.py.patched 2025-01-04 20:58:10.813174885 +0000 +@@ -130,7 +130,6 @@ + str(config_path), + "--output_dir", + str(wav_dir.name), +- "--json-input", # piper 1.1+ + ] + + if voice_speaker is not None: +@@ -148,6 +147,12 @@ + if self.args.noise_w: + piper_args.extend(["--noise-w", str(self.args.noise_w)]) + ++ if self.args.espeak_data_dir: ++ piper_args.extend(["--espeak_data", str(self.args.espeak_data_dir)]) ++ ++ if self.args.cuda: ++ piper_args.extend(["--cuda"]) ++ + _LOGGER.debug( + "Starting piper process: %s args=%s", self.args.piper, piper_args + ) diff --git a/patch/wyoming-piper_cuda.patch b/patch/wyoming-piper_cuda.patch deleted file mode 100644 index 44426a3..0000000 --- a/patch/wyoming-piper_cuda.patch +++ /dev/null @@ -1,30 +0,0 @@ ---- __main__.py 2025-01-04 17:48:27.645862671 +0000 -+++ __main__.py.patched 2025-01-04 17:51:50.193357609 +0000 -@@ -66,6 +66,15 @@ - help="Download latest voices.json during startup", - ) - # -+ parser.add_argument( -+ "--cuda", -+ action="store_true", -+ help="Use GPU" -+ ) -+ parser.add_argument( -+ "--espeak-data-dir", -+ help="Path to espeak-ng data directory" -+ ) -+ - ---- process.py 2025-01-04 17:48:27.653862810 +0000 -+++ process.py.patched 2025-01-04 17:52:48.494362993 +0000 -@@ -148,6 +148,14 @@ - if self.args.noise_w: - piper_args.extend(["--noise-w", str(self.args.noise_w)]) - -+ if self.args.espeak_data_dir: -+ piper_args.extend(["--espeak_data", str(self.args.espeak_data_dir)]) -+ -+ if self.args.cuda: -+ piper_args.extend(["--debug"]) -+ piper_args.extend(["--cuda"]) -+