From 99f093678912b7f7ec7a4f164e8f6de5fde26a5b Mon Sep 17 00:00:00 2001 From: Michael Hansen Date: Tue, 6 Jun 2023 17:19:36 -0500 Subject: [PATCH] Download during Docker build --- Dockerfile | 47 +++++++++++++++++------------------------ Dockerfile.dockerignore | 2 -- Makefile | 2 +- 3 files changed, 20 insertions(+), 31 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2fa146d..f7b258c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,45 +13,36 @@ ENV DEBIAN_FRONTEND=noninteractive WORKDIR /build -# Build minimal version of espeak-ng -ADD lib/espeak-ng-1.52-patched.tar.gz ./ -RUN cd espeak-ng && \ - ./autogen.sh && \ - ./configure \ - --without-pcaudiolib \ - --without-klatt \ - --without-speechplayer \ - --without-mbrola \ - --without-sonic \ - --with-extdict-cmn \ - --prefix=/usr && \ - make -j8 src/espeak-ng src/speak-ng && \ - make && \ - make install +RUN mkdir -p "lib/Linux-$(uname -m)" -# Copy onnxruntime library -COPY lib/onnxruntime-linux-*.tgz ./lib/ -RUN export ONNX_DIR="./lib/Linux-$(uname -m)" && \ - mkdir -p "${ONNX_DIR}" && \ - tar -C "${ONNX_DIR}" \ - --strip-components 1 \ - -xvf "lib/onnxruntime-linux-${TARGETARCH}${TARGETVARIANT}.tgz" +ARG ONNXRUNTIME_VERSION='1.14.1' +RUN if [ "${TARGETARCH}${TARGETVARIANT}" = 'amd64' ]; then \ + ONNXRUNTIME_ARCH='x64'; \ + else \ + ONNXRUNTIME_ARCH="$(uname -m)"; \ + fi && \ + curl -L "https://github.com/microsoft/onnxruntime/releases/download/v${ONNXRUNTIME_VERSION}/onnxruntime-linux-${ONNXRUNTIME_ARCH}-${ONNXRUNTIME_VERSION}.tgz" | \ + tar -C "lib/Linux-$(uname -m)" -xzvf - && \ + mv "lib/Linux-$(uname -m)"/onnxruntime-* \ + "lib/Linux-$(uname -m)/onnxruntime" + +ARG PIPER_PHONEMIZE_VERSION='1.0.0' +RUN mkdir -p "lib/Linux-$(uname -m)/piper_phonemize" && \ + curl -L "https://github.com/rhasspy/piper-phonemize/releases/download/v${PIPER_PHONEMIZE_VERSION}/libpiper_phonemize-${TARGETARCH}${TARGETVARIANT}.tar.gz" | \ + tar -C "lib/Linux-$(uname -m)/piper_phonemize" -xzvf - # Build piper binary COPY Makefile ./ COPY src/cpp/ ./src/cpp/ -RUN make no-pcaudio +RUN make # Do a test run -RUN /build/build/piper --help +RUN ./build/piper --help # Build .tar.gz to keep symlinks WORKDIR /dist RUN mkdir -p piper && \ - cp -d /usr/lib64/libespeak-ng.so* ./piper/ && \ - cp -dR /usr/share/espeak-ng-data ./piper/ && \ - find /build/lib/ -name 'libonnxruntime.so.*' -exec cp -d {} ./piper/ \; && \ - cp /build/build/piper ./piper/ && \ + cp -dR /build/build/*.so* /build/build/espeak-ng-data /build/build/piper ./piper/ && \ tar -czf "piper_${TARGETARCH}${TARGETVARIANT}.tar.gz" piper/ # ----------------------------------------------------------------------------- diff --git a/Dockerfile.dockerignore b/Dockerfile.dockerignore index f3d5121..b205fa2 100644 --- a/Dockerfile.dockerignore +++ b/Dockerfile.dockerignore @@ -1,5 +1,3 @@ * !Makefile !src/cpp/ -!lib/onnxruntime*.tgz -!lib/espeak-ng*.tar.gz diff --git a/Makefile b/Makefile index 4effe8c..ee7d2aa 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ LIB_DIR := lib/Linux-$(shell uname -m) piper: mkdir -p build cd build && cmake ../src/cpp -DCMAKE_BUILD_TYPE=Release && make - cp -aR $(LIB_DIR)/piper_phonemize/espeak-ng-data $(LIB_DIR)/piper_phonemize/lib/*.so* build/ + cp -aR $(LIB_DIR)/piper_phonemize/lib/espeak-ng-data $(LIB_DIR)/piper_phonemize/lib/*.so* build/ cp -a $(LIB_DIR)/onnxruntime/lib/*.so* build/ clean: