From bde87d00b971a78c9200791e5f1994b71ebac18f Mon Sep 17 00:00:00 2001 From: Gianluca Boiano <491117+M0Rf30@users.noreply.github.com> Date: Sat, 11 Nov 2023 18:40:26 +0100 Subject: [PATCH] deps(go-piper): update to 2023.11.6-3 (#1257) Signed-off-by: Gianluca Boiano --- .github/workflows/test.yml | 25 +++++++------------------ Dockerfile | 26 ++++---------------------- Makefile | 17 +++++++---------- entrypoint.sh | 2 +- 4 files changed, 19 insertions(+), 51 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5f03a780..2ece8a57 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -80,24 +80,13 @@ jobs: sudo rm -rfv /usr/bin/conda || true PATH=$PATH:/opt/conda/bin make -C extra/grpc/huggingface - # Pre-build stable diffusion before we install a newever version of abseil (not compatible with stablediffusion-ncn) - GO_TAGS="tts stablediffusion" GRPC_BACKENDS=backend-assets/grpc/stablediffusion make build + # Pre-build piper before we start tests in order to have shared libraries in place + make go-piper && \ + GO_TAGS="tts" make -C go-piper piper.o && \ + sudo cp -rfv go-piper/piper/build/pi/lib/. /usr/lib/ && \ - sudo mkdir /build && sudo chmod -R 777 /build && cd /build && \ - curl -L "https://github.com/gabime/spdlog/archive/refs/tags/v1.11.0.tar.gz" | \ - tar -xzvf - && \ - mkdir -p "spdlog-1.11.0/build" && \ - cd "spdlog-1.11.0/build" && \ - cmake .. && \ - make -j8 && \ - sudo cmake --install . --prefix /usr && mkdir -p "lib/Linux-$(uname -m)" && \ - cd /build && \ - mkdir -p "lib/Linux-$(uname -m)/piper_phonemize" && \ - curl -L "https://github.com/rhasspy/piper-phonemize/releases/download/v1.0.0/libpiper_phonemize-amd64.tar.gz" | \ - tar -C "lib/Linux-$(uname -m)/piper_phonemize" -xzvf - && ls -liah /build/lib/Linux-$(uname -m)/piper_phonemize/ && \ - sudo cp -rfv /build/lib/Linux-$(uname -m)/piper_phonemize/lib/. /usr/lib/ && \ - sudo ln -s /usr/lib/libpiper_phonemize.so /usr/lib/libpiper_phonemize.so.1 && \ - sudo cp -rfv /build/lib/Linux-$(uname -m)/piper_phonemize/include/. /usr/include/ + # Pre-build stable diffusion before we install a newer version of abseil (not compatible with stablediffusion-ncn) + GO_TAGS="stablediffusion tts" GRPC_BACKENDS=backend-assets/grpc/stablediffusion make build git clone --recurse-submodules -b v1.58.0 --depth 1 --shallow-submodules https://github.com/grpc/grpc && \ cd grpc && mkdir -p cmake/build && cd cmake/build && cmake -DgRPC_INSTALL=ON \ @@ -105,7 +94,7 @@ jobs: ../.. && sudo make -j12 install - name: Test run: | - ESPEAK_DATA="/build/lib/Linux-$(uname -m)/piper_phonemize/lib/espeak-ng-data" GO_TAGS="tts stablediffusion" make test + GO_TAGS="stablediffusion tts" make test tests-apple: runs-on: macOS-latest diff --git a/Dockerfile b/Dockerfile index 157c6759..2091e2e3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,8 +8,6 @@ FROM golang:$GO_VERSION as requirements-core ARG BUILD_TYPE ARG CUDA_MAJOR_VERSION=11 ARG CUDA_MINOR_VERSION=7 -ARG SPDLOG_VERSION="1.11.0" -ARG PIPER_PHONEMIZE_VERSION='1.0.0' ARG TARGETARCH ARG TARGETVARIANT @@ -52,28 +50,9 @@ RUN ln -s /usr/include/opencv4/opencv2 /usr/include/opencv2 WORKDIR /build -# piper requirements -# Use pre-compiled Piper phonemization library (includes onnxruntime) -#RUN if echo "${GO_TAGS}" | grep -q "tts"; then \ RUN test -n "$TARGETARCH" \ || (echo 'warn: missing $TARGETARCH, either set this `ARG` manually, or run using `docker buildkit`') -RUN curl -L "https://github.com/gabime/spdlog/archive/refs/tags/v${SPDLOG_VERSION}.tar.gz" | \ - tar -xzvf - && \ - mkdir -p "spdlog-${SPDLOG_VERSION}/build" && \ - cd "spdlog-${SPDLOG_VERSION}/build" && \ - cmake .. && \ - make -j8 && \ - cmake --install . --prefix /usr && mkdir -p "lib/Linux-$(uname -m)" && \ - cd /build && \ - 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:-$(go env GOARCH)}${TARGETVARIANT}.tar.gz" | \ - tar -C "lib/Linux-$(uname -m)/piper_phonemize" -xzvf - && ls -liah /build/lib/Linux-$(uname -m)/piper_phonemize/ && \ - cp -rfv /build/lib/Linux-$(uname -m)/piper_phonemize/lib/. /usr/lib/ && \ - ln -s /usr/lib/libpiper_phonemize.so /usr/lib/libpiper_phonemize.so.1 && \ - cp -rfv /build/lib/Linux-$(uname -m)/piper_phonemize/include/. /usr/include/ && \ - rm spdlog-${SPDLOG_VERSION} -rf - # Extras requirements FROM requirements-core as requirements-extras @@ -137,7 +116,7 @@ RUN if [ "${BUILD_GRPC}" = "true" ]; then \ ; fi # Rebuild with defaults backends -RUN ESPEAK_DATA=/build/lib/Linux-$(uname -m)/piper_phonemize/lib/espeak-ng-data make build +RUN make build ################################### ################################### @@ -175,6 +154,9 @@ RUN make prepare-sources # Copy the binary COPY --from=builder /build/local-ai ./ +# Copy shared libraries for piper +COPY --from=builder /build/go-piper/piper/build/pi/lib/* /usr/lib/ + # do not let stablediffusion rebuild (requires an older version of absl) COPY --from=builder /build/backend-assets/grpc/stablediffusion ./backend-assets/grpc/stablediffusion diff --git a/Makefile b/Makefile index 5a819fa6..23db8585 100644 --- a/Makefile +++ b/Makefile @@ -28,7 +28,7 @@ WHISPER_CPP_VERSION?=85ed71aaec8e0612a84c0b67804bde75aa75a273 BERT_VERSION?=6abe312cded14042f6b7c3cd8edf082713334a4d # go-piper version -PIPER_VERSION?=56b8a81b4760a6fbee1a82e62f007ae7e8f010a7 +PIPER_VERSION?=736f6fb639ab8e3397356e48eeb6bdcb9da88a78 # stablediffusion version STABLEDIFFUSION_VERSION?=d89260f598afb809279bc72aa0107b4292587632 @@ -52,7 +52,6 @@ override LD_FLAGS += -X "github.com/go-skynet/LocalAI/internal.Version=$(VERSION override LD_FLAGS += -X "github.com/go-skynet/LocalAI/internal.Commit=$(shell git rev-parse HEAD)" OPTIONAL_TARGETS?= -ESPEAK_DATA?= OS := $(shell uname -s) ARCH := $(shell uname -m) @@ -120,6 +119,8 @@ endif ifeq ($(findstring tts,$(GO_TAGS)),tts) # OPTIONAL_TARGETS+=go-piper/libpiper_binding.a # OPTIONAL_TARGETS+=backend-assets/espeak-ng-data + PIPER_CGO_CXXFLAGS+=-I$(shell pwd)/go-piper/piper/src/cpp -I$(shell pwd)/go-piper/piper/build/fi/include -I$(shell pwd)/go-piper/piper/build/pi/include -I$(shell pwd)/go-piper/piper/build/si/include + PIPER_CGO_LDFLAGS+=-L$(shell pwd)/go-piper/piper/build/fi/lib -L$(shell pwd)/go-piper/piper/build/pi/lib -L$(shell pwd)/go-piper/piper/build/si/lib -lfmt -lspdlog OPTIONAL_GRPC+=backend-assets/grpc/piper endif @@ -175,14 +176,10 @@ backend-assets/gpt4all: gpt4all/gpt4all-bindings/golang/libgpt4all.a @cp gpt4all/gpt4all-bindings/golang/buildllm/*.dylib backend-assets/gpt4all/ || true @cp gpt4all/gpt4all-bindings/golang/buildllm/*.dll backend-assets/gpt4all/ || true -backend-assets/espeak-ng-data: +backend-assets/espeak-ng-data: go-piper mkdir -p backend-assets/espeak-ng-data -ifdef ESPEAK_DATA - @cp -rf $(ESPEAK_DATA)/. backend-assets/espeak-ng-data -else - @echo "ESPEAK_DATA not set, skipping tts. Note that this will break the tts functionality." - @touch backend-assets/espeak-ng-data/keep -endif + $(MAKE) -C go-piper piper.o + @cp -rf go-piper/piper/build/pi/share/espeak-ng-data/. backend-assets/espeak-ng-data gpt4all/gpt4all-bindings/golang/libgpt4all.a: gpt4all $(MAKE) -C gpt4all/gpt4all-bindings/golang/ libgpt4all.a @@ -503,7 +500,7 @@ backend-assets/grpc/stablediffusion: backend-assets/grpc fi backend-assets/grpc/piper: backend-assets/grpc backend-assets/espeak-ng-data go-piper/libpiper_binding.a - CGO_LDFLAGS="$(CGO_LDFLAGS)" LIBRARY_PATH=$(shell pwd)/go-piper \ + CGO_CXXFLAGS="$(PIPER_CGO_CXXFLAGS)" CGO_LDFLAGS="$(PIPER_CGO_LDFLAGS)" LIBRARY_PATH=$(shell pwd)/go-piper \ $(GOCMD) build -ldflags "$(LD_FLAGS)" -tags "$(GO_TAGS)" -o backend-assets/grpc/piper ./cmd/grpc/piper/ backend-assets/grpc/whisper: backend-assets/grpc whisper.cpp/libwhisper.a diff --git a/entrypoint.sh b/entrypoint.sh index 30108a69..2412364a 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -5,7 +5,7 @@ cd /build if [ "$REBUILD" != "false" ]; then rm -rf ./local-ai - ESPEAK_DATA=/build/lib/Linux-$(uname -m)/piper_phonemize/lib/espeak-ng-data make build -j${BUILD_PARALLELISM:-1} + make build -j${BUILD_PARALLELISM:-1} else echo "@@@@@" echo "Skipping rebuild"