Skip to content

Commit bf01ec1

Browse files
committed
Makefile: update go-piper with piper 2023.11.6-3
Signed-off-by: Gianluca Boiano <[email protected]>
1 parent 3b4c5d5 commit bf01ec1

File tree

4 files changed

+19
-51
lines changed

4 files changed

+19
-51
lines changed

.github/workflows/test.yml

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -80,32 +80,21 @@ jobs:
8080
sudo rm -rfv /usr/bin/conda || true
8181
PATH=$PATH:/opt/conda/bin make -C extra/grpc/huggingface
8282
83-
# Pre-build stable diffusion before we install a newever version of abseil (not compatible with stablediffusion-ncn)
84-
GO_TAGS="tts stablediffusion" GRPC_BACKENDS=backend-assets/grpc/stablediffusion make build
83+
# Pre-build piper before we start tests in order to have shared libraries in place
84+
make go-piper && \
85+
GO_TAGS="tts" make -C go-piper piper.o && \
86+
sudo cp -rfv go-piper/piper/build/pi/lib/. /usr/lib/ && \
8587
86-
sudo mkdir /build && sudo chmod -R 777 /build && cd /build && \
87-
curl -L "https://github.com/gabime/spdlog/archive/refs/tags/v1.11.0.tar.gz" | \
88-
tar -xzvf - && \
89-
mkdir -p "spdlog-1.11.0/build" && \
90-
cd "spdlog-1.11.0/build" && \
91-
cmake .. && \
92-
make -j8 && \
93-
sudo cmake --install . --prefix /usr && mkdir -p "lib/Linux-$(uname -m)" && \
94-
cd /build && \
95-
mkdir -p "lib/Linux-$(uname -m)/piper_phonemize" && \
96-
curl -L "https://github.com/rhasspy/piper-phonemize/releases/download/v1.0.0/libpiper_phonemize-amd64.tar.gz" | \
97-
tar -C "lib/Linux-$(uname -m)/piper_phonemize" -xzvf - && ls -liah /build/lib/Linux-$(uname -m)/piper_phonemize/ && \
98-
sudo cp -rfv /build/lib/Linux-$(uname -m)/piper_phonemize/lib/. /usr/lib/ && \
99-
sudo ln -s /usr/lib/libpiper_phonemize.so /usr/lib/libpiper_phonemize.so.1 && \
100-
sudo cp -rfv /build/lib/Linux-$(uname -m)/piper_phonemize/include/. /usr/include/
88+
# Pre-build stable diffusion before we install a newer version of abseil (not compatible with stablediffusion-ncn)
89+
GO_TAGS="stablediffusion tts" GRPC_BACKENDS=backend-assets/grpc/stablediffusion make build
10190
10291
git clone --recurse-submodules -b v1.58.0 --depth 1 --shallow-submodules https://github.com/grpc/grpc && \
10392
cd grpc && mkdir -p cmake/build && cd cmake/build && cmake -DgRPC_INSTALL=ON \
10493
-DgRPC_BUILD_TESTS=OFF \
10594
../.. && sudo make -j12 install
10695
- name: Test
10796
run: |
108-
ESPEAK_DATA="/build/lib/Linux-$(uname -m)/piper_phonemize/lib/espeak-ng-data" GO_TAGS="tts stablediffusion" make test
97+
GO_TAGS="stablediffusion tts" make test
10998
11099
tests-apple:
111100
runs-on: macOS-latest

Dockerfile

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ FROM golang:$GO_VERSION as requirements-core
88
ARG BUILD_TYPE
99
ARG CUDA_MAJOR_VERSION=11
1010
ARG CUDA_MINOR_VERSION=7
11-
ARG SPDLOG_VERSION="1.11.0"
12-
ARG PIPER_PHONEMIZE_VERSION='1.0.0'
1311
ARG TARGETARCH
1412
ARG TARGETVARIANT
1513

@@ -52,28 +50,9 @@ RUN ln -s /usr/include/opencv4/opencv2 /usr/include/opencv2
5250

5351
WORKDIR /build
5452

55-
# piper requirements
56-
# Use pre-compiled Piper phonemization library (includes onnxruntime)
57-
#RUN if echo "${GO_TAGS}" | grep -q "tts"; then \
5853
RUN test -n "$TARGETARCH" \
5954
|| (echo 'warn: missing $TARGETARCH, either set this `ARG` manually, or run using `docker buildkit`')
6055

61-
RUN curl -L "https://github.com/gabime/spdlog/archive/refs/tags/v${SPDLOG_VERSION}.tar.gz" | \
62-
tar -xzvf - && \
63-
mkdir -p "spdlog-${SPDLOG_VERSION}/build" && \
64-
cd "spdlog-${SPDLOG_VERSION}/build" && \
65-
cmake .. && \
66-
make -j8 && \
67-
cmake --install . --prefix /usr && mkdir -p "lib/Linux-$(uname -m)" && \
68-
cd /build && \
69-
mkdir -p "lib/Linux-$(uname -m)/piper_phonemize" && \
70-
curl -L "https://github.com/rhasspy/piper-phonemize/releases/download/v${PIPER_PHONEMIZE_VERSION}/libpiper_phonemize-${TARGETARCH:-$(go env GOARCH)}${TARGETVARIANT}.tar.gz" | \
71-
tar -C "lib/Linux-$(uname -m)/piper_phonemize" -xzvf - && ls -liah /build/lib/Linux-$(uname -m)/piper_phonemize/ && \
72-
cp -rfv /build/lib/Linux-$(uname -m)/piper_phonemize/lib/. /usr/lib/ && \
73-
ln -s /usr/lib/libpiper_phonemize.so /usr/lib/libpiper_phonemize.so.1 && \
74-
cp -rfv /build/lib/Linux-$(uname -m)/piper_phonemize/include/. /usr/include/ && \
75-
rm spdlog-${SPDLOG_VERSION} -rf
76-
7756
# Extras requirements
7857
FROM requirements-core as requirements-extras
7958

@@ -137,7 +116,7 @@ RUN if [ "${BUILD_GRPC}" = "true" ]; then \
137116
; fi
138117

139118
# Rebuild with defaults backends
140-
RUN ESPEAK_DATA=/build/lib/Linux-$(uname -m)/piper_phonemize/lib/espeak-ng-data make build
119+
RUN make build
141120

142121
###################################
143122
###################################
@@ -175,6 +154,9 @@ RUN make prepare-sources
175154
# Copy the binary
176155
COPY --from=builder /build/local-ai ./
177156

157+
# Copy shared libraries for piper
158+
COPY --from=builder /build/go-piper/piper/build/pi/lib/* /usr/lib/
159+
178160
# do not let stablediffusion rebuild (requires an older version of absl)
179161
COPY --from=builder /build/backend-assets/grpc/stablediffusion ./backend-assets/grpc/stablediffusion
180162

Makefile

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ WHISPER_CPP_VERSION?=85ed71aaec8e0612a84c0b67804bde75aa75a273
2828
BERT_VERSION?=6abe312cded14042f6b7c3cd8edf082713334a4d
2929

3030
# go-piper version
31-
PIPER_VERSION?=56b8a81b4760a6fbee1a82e62f007ae7e8f010a7
31+
PIPER_VERSION?=736f6fb639ab8e3397356e48eeb6bdcb9da88a78
3232

3333
# stablediffusion version
3434
STABLEDIFFUSION_VERSION?=d89260f598afb809279bc72aa0107b4292587632
@@ -52,7 +52,6 @@ override LD_FLAGS += -X "github.com/go-skynet/LocalAI/internal.Version=$(VERSION
5252
override LD_FLAGS += -X "github.com/go-skynet/LocalAI/internal.Commit=$(shell git rev-parse HEAD)"
5353

5454
OPTIONAL_TARGETS?=
55-
ESPEAK_DATA?=
5655

5756
OS := $(shell uname -s)
5857
ARCH := $(shell uname -m)
@@ -120,6 +119,8 @@ endif
120119
ifeq ($(findstring tts,$(GO_TAGS)),tts)
121120
# OPTIONAL_TARGETS+=go-piper/libpiper_binding.a
122121
# OPTIONAL_TARGETS+=backend-assets/espeak-ng-data
122+
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
123+
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
123124
OPTIONAL_GRPC+=backend-assets/grpc/piper
124125
endif
125126

@@ -175,14 +176,10 @@ backend-assets/gpt4all: gpt4all/gpt4all-bindings/golang/libgpt4all.a
175176
@cp gpt4all/gpt4all-bindings/golang/buildllm/*.dylib backend-assets/gpt4all/ || true
176177
@cp gpt4all/gpt4all-bindings/golang/buildllm/*.dll backend-assets/gpt4all/ || true
177178

178-
backend-assets/espeak-ng-data:
179+
backend-assets/espeak-ng-data: go-piper
179180
mkdir -p backend-assets/espeak-ng-data
180-
ifdef ESPEAK_DATA
181-
@cp -rf $(ESPEAK_DATA)/. backend-assets/espeak-ng-data
182-
else
183-
@echo "ESPEAK_DATA not set, skipping tts. Note that this will break the tts functionality."
184-
@touch backend-assets/espeak-ng-data/keep
185-
endif
181+
$(MAKE) -C go-piper piper.o
182+
@cp -rf go-piper/piper/build/pi/share/espeak-ng-data/. backend-assets/espeak-ng-data
186183

187184
gpt4all/gpt4all-bindings/golang/libgpt4all.a: gpt4all
188185
$(MAKE) -C gpt4all/gpt4all-bindings/golang/ libgpt4all.a
@@ -503,7 +500,7 @@ backend-assets/grpc/stablediffusion: backend-assets/grpc
503500
fi
504501

505502
backend-assets/grpc/piper: backend-assets/grpc backend-assets/espeak-ng-data go-piper/libpiper_binding.a
506-
CGO_LDFLAGS="$(CGO_LDFLAGS)" LIBRARY_PATH=$(shell pwd)/go-piper \
503+
CGO_CXXFLAGS="$(PIPER_CGO_CXXFLAGS)" CGO_LDFLAGS="$(PIPER_CGO_LDFLAGS)" LIBRARY_PATH=$(shell pwd)/go-piper \
507504
$(GOCMD) build -ldflags "$(LD_FLAGS)" -tags "$(GO_TAGS)" -o backend-assets/grpc/piper ./cmd/grpc/piper/
508505

509506
backend-assets/grpc/whisper: backend-assets/grpc whisper.cpp/libwhisper.a

entrypoint.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ cd /build
55

66
if [ "$REBUILD" != "false" ]; then
77
rm -rf ./local-ai
8-
ESPEAK_DATA=/build/lib/Linux-$(uname -m)/piper_phonemize/lib/espeak-ng-data make build -j${BUILD_PARALLELISM:-1}
8+
make build -j${BUILD_PARALLELISM:-1}
99
else
1010
echo "@@@@@"
1111
echo "Skipping rebuild"

0 commit comments

Comments
 (0)