Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion Dockerfile.debian-static
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ COPY --from=xx / /
# Install host dependencies
RUN apt-get update -y && apt-get install --no-install-recommends -y \
lsb-release ca-certificates curl wget gnupg \
cmake ninja-build git clang xz-utils
cmake ninja-build git clang xz-utils file

# Set up llvm's apt repo
ARG LLVM_VERSION
Expand Down Expand Up @@ -85,6 +85,18 @@ RUN cmake -S /src -B /build -G Ninja \
-DWASMEDGE_USE_LLVM=ON

RUN cmake --build /build -- install

# Link a consumer against the installed static library
RUN /bin/bash <<EOT
set -ex
cat <<EOF > /smoke.c
#include <wasmedge/wasmedge.h>
int main(void) { return WasmEdge_VersionGet() == 0; }
EOF
xx-clang /smoke.c -I/install/include -L/install/lib -lwasmedge -lstdc++ -lm -lrt -ldl -lpthread -o /smoke
xx-verify /smoke
EOT

RUN cmake --build /build -- package
RUN mv /build/WasmEdge-*-Linux.tar.gz $(echo build/WasmEdge-*-Linux.tar.gz | sed 's|WasmEdge-\(.*\)-Linux.tar.gz|WasmEdge-\1-debian'$(lsb_release -sr)'_'$(xx-info march)'_static.tar.gz|')

Expand Down
7 changes: 0 additions & 7 deletions Dockerfile.manylinux_2_28-plugins-deps
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@ RUN cd && (yum check-update || true) && \
### deps for all ###
FROM deps-${TARGETARCH} AS final

COPY scripts/opencvmini/install-opencvmini.sh .
ENV OPENCV_VERSION="4.8.0"
RUN [ "/bin/bash", "install-opencvmini.sh" ]

COPY scripts/wasi-crypto/build-openssl.sh .
ENV OpenSSL_DIR="/root/openssl-1.1.1n/openssl"
RUN [ "/bin/bash", "build-openssl.sh" ]
Expand All @@ -43,9 +39,6 @@ ENV LD_LIBRARY_PATH=/root/FFmpeg-n7.1.1/output/lib${LD_LIBRARY_PATH:+:${LD_LIBRA
ENV OPENVINO_VERSION="2025.0.0"
ENV OPENVINO_YEAR="2025"

COPY scripts/wasi-nn/install-onnxruntime.sh .
RUN [ "/bin/bash", "install-onnxruntime.sh" ]

COPY scripts/wasi-nn/libpiper.patch .
COPY scripts/wasi-nn/install-libpiper.sh .
RUN [ "/bin/bash", "install-libpiper.sh" ]
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.ubuntu-base
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
RUN curl -sSf https://apt.kitware.com/kitware-archive.sh | sh
RUN apt-get install -y cmake

RUN wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - \
RUN curl -4 -sSfL --retry 5 https://apt.llvm.org/llvm-snapshot.gpg.key > /etc/apt/trusted.gpg.d/apt.llvm.org.asc \
&& echo "deb http://apt.llvm.org/focal llvm-toolchain-focal-18 main" | tee /etc/apt/sources.list.d/llvm.list

RUN apt-get install -y \
Expand All @@ -37,8 +37,8 @@

ENV CC=/usr/bin/clang-18
ENV CXX=/usr/bin/clang++-18

Check warning on line 40 in Dockerfile.ubuntu-base

View workflow job for this annotation

GitHub Actions / Ubuntu (default)

Variables should be defined before their use

UndefinedVar: Usage of undefined variable '$PKG_CONFIG_PATH' More info: https://docs.docker.com/go/dockerfile/rule/undefined-var/
### deps for ubuntu 22.04 ###

Check warning on line 41 in Dockerfile.ubuntu-base

View workflow job for this annotation

GitHub Actions / Ubuntu (default)

Variables should be defined before their use

UndefinedVar: Usage of undefined variable '$LD_LIBRARY_PATH' More info: https://docs.docker.com/go/dockerfile/rule/undefined-var/
FROM base AS deps-22

RUN curl -sSf https://apt.kitware.com/kitware-archive.sh | sh
Expand Down
9 changes: 0 additions & 9 deletions Dockerfile.ubuntu-plugins-deps
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,6 @@ FROM deps-${UBUNTU_VER} AS deps-all

WORKDIR /root

COPY scripts/opencvmini/install-opencvmini.sh .
ENV OPENCV_VERSION="4.8.0"
RUN [ "/bin/bash", "install-opencvmini.sh" ]

COPY scripts/wasi-nn/install-pytorch.sh .
ENV PYTORCH_VERSION="2.12.1"
ENV PYTORCH_INSTALL_TO="/usr/local/libtorch"
Expand All @@ -72,9 +68,6 @@ RUN [ "/bin/bash", "install-openvino-genai.sh" ]
RUN [ "ls", "-al" ]
RUN [ "/bin/bash", "-c", "echo \"source ./openvino_genai/setupvars.sh\" >> .bashrc" ]

COPY scripts/wasi-nn/install-onnxruntime.sh .
RUN [ "/bin/bash", "install-onnxruntime.sh" ]

COPY scripts/wasi-nn/libpiper.patch .
COPY scripts/wasi-nn/install-libpiper.sh .
RUN [ "/bin/bash", "install-libpiper.sh" ]
Expand All @@ -86,11 +79,9 @@ RUN [ "/bin/bash", "install-chattts.sh" ]
FROM deps-all AS clean-apt

RUN rm -f \
install-opencvmini.sh \
install-ffmpeg-v7.1.1.sh \
install-pytorch.sh \
install-openvino.sh \
install-onnxruntime.sh \
install-openvino-genai.sh \
install-chattts.sh \
install-libpiper.sh
Expand Down
12 changes: 8 additions & 4 deletions docker-bake.alpine-base.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@ group "default" {
target "alpine-base" {
dockerfile = "Dockerfile.alpine-base"
context = "."
# Build for both major architectures at once
platforms = ["linux/amd64", "linux/arm64"]
# Tag it clearly so we can use it later
tags = ["wasmedge/wasmedge:alpine-base-3.23"]

matrix = {
arch = ["amd64", "arm64"]
}

name = "alpine-base-${arch}"
platforms = ["linux/${arch}"]
tags = ["wasmedge/wasmedge:alpine-base-3.23-${arch}"]
}
2 changes: 1 addition & 1 deletion scripts/ffmpeg/install-ffmpeg-v7.1.1.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ unzip ffmpeg.zip
mkdir -p FFmpeg-n7.1.1/output
cd FFmpeg-n7.1.1
./configure --prefix=$(pwd)/output --enable-gpl --enable-nonfree --enable-shared --disable-static
make && make install
make -j"$(nproc)" && make install
cd ..

rm -rf ffmpeg.zip
19 changes: 0 additions & 19 deletions scripts/opencvmini/install-opencvmini.sh

This file was deleted.

47 changes: 42 additions & 5 deletions scripts/wasi-nn/install-libpiper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,53 @@ if [ ! -f "${PATCH_PATH}" ]; then
fi

PIPER_REPO="https://github.com/OHF-Voice/piper1-gpl.git"
PIPER_COMMIT="32b95f8c1f0dc0ce27a6acd1143de331f61af777"
PIPER_COMMIT="639388b6317fc4731e91d53da42aea68fd4166ff"
PIPER_INSTALL_TO="/usr/local"
ONNXRUNTIME_VERSION="1.22.0"

case "$(uname -m)" in
'x86_64') ;;
'aarch64') ;;
'x86_64')
ONNXRUNTIME_ARCH="x64"
ONNXRUNTIME_RID="linux-x64"
;;
'aarch64')
ONNXRUNTIME_ARCH="aarch64"
ONNXRUNTIME_RID="linux-arm64"
;;
*)
echo "Unsupported architecture for libpiper: $(uname -m)" >&2
exit 1
;;
esac

ONNXRUNTIME_NAME="onnxruntime-linux-${ONNXRUNTIME_ARCH}-${ONNXRUNTIME_VERSION}"
ONNXRUNTIME_PACKAGE="microsoft.ml.onnxruntime.${ONNXRUNTIME_VERSION}.nupkg"
ONNXRUNTIME_URL="https://api.nuget.org/v3-flatcontainer/microsoft.ml.onnxruntime/${ONNXRUNTIME_VERSION}/${ONNXRUNTIME_PACKAGE}"
ONNXRUNTIME_PACKAGE_SHA256="d571e63a2329baacb713f441e65ad75284de354db6e1ac435fe4bebbb417986a"

rm -rf "${ONNXRUNTIME_NAME}" "${ONNXRUNTIME_PACKAGE}"
DOWNLOADED=0
for _ in 1 2 3 4 5; do
if curl -fL -o "${ONNXRUNTIME_PACKAGE}" "${ONNXRUNTIME_URL}"; then
DOWNLOADED=1
break
fi
sleep 10
done
[ "${DOWNLOADED}" -eq 1 ]
echo "${ONNXRUNTIME_PACKAGE_SHA256} ${ONNXRUNTIME_PACKAGE}" | sha256sum -c
mkdir -p "${ONNXRUNTIME_NAME}/include" "${ONNXRUNTIME_NAME}/lib"
unzip -q "${ONNXRUNTIME_PACKAGE}" \
"build/native/include/*" \
"runtimes/${ONNXRUNTIME_RID}/native/libonnxruntime.so" \
"runtimes/${ONNXRUNTIME_RID}/native/libonnxruntime_providers_shared.so" \
-d .onnxruntime-package
cp -R .onnxruntime-package/build/native/include/. "${ONNXRUNTIME_NAME}/include/"
cp .onnxruntime-package/runtimes/${ONNXRUNTIME_RID}/native/libonnxruntime.so "${ONNXRUNTIME_NAME}/lib/"
cp .onnxruntime-package/runtimes/${ONNXRUNTIME_RID}/native/libonnxruntime_providers_shared.so "${ONNXRUNTIME_NAME}/lib/"
rm -rf .onnxruntime-package
ONNXRUNTIME_DIR="$(pwd)/${ONNXRUNTIME_NAME}"

rm -rf piper-source
git clone --depth 1 "${PIPER_REPO}" piper-source
cd piper-source
Expand All @@ -37,9 +72,11 @@ cd libpiper

cmake -Bbuild \
-DCMAKE_BUILD_TYPE=Release \
-DPIPER_BUILD_EXE=OFF \
-DCMAKE_INSTALL_PREFIX="${PIPER_INSTALL_TO}" \
-DBUILD_SHARED_LIBS=OFF \
-DCMAKE_POSITION_INDEPENDENT_CODE=ON
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \
-DONNXRUNTIME_DIR="${ONNXRUNTIME_DIR}"
cmake --build build --parallel $(nproc)
cmake --install build

Expand Down Expand Up @@ -75,6 +112,6 @@ else
fi

cd ../..
rm -rf piper-source
rm -rf piper-source "${ONNXRUNTIME_NAME}" "${ONNXRUNTIME_PACKAGE}"

ldconfig
27 changes: 0 additions & 27 deletions scripts/wasi-nn/install-onnxruntime.sh

This file was deleted.

86 changes: 78 additions & 8 deletions scripts/wasi-nn/libpiper.patch
Original file line number Diff line number Diff line change
@@ -1,22 +1,92 @@
diff --git a/libpiper/CMakeLists.txt b/libpiper/CMakeLists.txt
index 57349c1..2e7ddd8 100644
index d43e714..a59d625 100644
--- a/libpiper/CMakeLists.txt
+++ b/libpiper/CMakeLists.txt
@@ -2,6 +2,8 @@
@@ -2,6 +2,9 @@
cmake_minimum_required(VERSION 3.26)
project(piper LANGUAGES C CXX)

+option(BUILD_SHARED_LIBS "Build using shared libraries" OFF)
+option(PIPER_BUILD_EXE "Build the piper command line tool" ON)
+
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
@@ -112,7 +114,7 @@ endif()


@@ -141,7 +144,7 @@ endif()
include(ClangTidy.cmake)
# ---- libpiper ---

-add_library(piper SHARED
+add_library(piper
${CMAKE_CURRENT_SOURCE_DIR}/src/piper.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/chinese_phonemizer.cpp
)

@@ -159,10 +162,12 @@ target_link_libraries(piper
)

# ---- piper exe ---
-add_subdirectory(src/main)
+if(PIPER_BUILD_EXE)
+ add_subdirectory(src/main)
+endif()

# ---- version
-file(READ ${CMAKE_SOURCE_DIR}/../setup.py SETUP_PY_CONTENTS)
+file(READ ${CMAKE_CURRENT_SOURCE_DIR}/../setup.py SETUP_PY_CONTENTS)
string(REGEX MATCH "version=\"([0-9]+\\.[0-9]+\\.[0-9]+)\"" _ ${SETUP_PY_CONTENTS})
set(PIPER_VERSION ${CMAKE_MATCH_1})

diff --git a/libpiper/src/piper.cpp b/libpiper/src/piper.cpp
index 56b61b0..608b5be 100644
--- a/libpiper/src/piper.cpp
+++ b/libpiper/src/piper.cpp
@@ -4,6 +4,7 @@

#include <array>
#include <cstddef>
+#include <cstdio>
#include <filesystem>
#include <fstream>
#include <limits>
@@ -22,6 +23,7 @@
#define PIPER_VERSION "0.0.1"
#endif

+#include <espeak-ng/espeak_ng.h>
#include <espeak-ng/speak_lib.h>

using json = nlohmann::json;
@@ -95,13 +97,19 @@ auto piper_create_with_options(const piper_create_options *options)
phoneme_type = config["phoneme_type"].get<PhonemeType>();
}

- if (phoneme_type == PhonemeType::Espeak &&
- espeak_Initialize(AUDIO_OUTPUT_SYNCHRONOUS, 0, final_espeak_data_path,
- 0) < 0) {
- return nullptr;
+ if (phoneme_type == PhonemeType::Espeak) {
+ espeak_ng_InitializePath(final_espeak_data_path);
+ espeak_ng_ERROR_CONTEXT espeak_context = nullptr;
+ espeak_ng_STATUS espeak_status = espeak_ng_Initialize(&espeak_context);
+ if (espeak_status != ENS_OK) {
+ espeak_ng_PrintStatusCodeMessage(espeak_status, stderr, espeak_context);
+ espeak_ng_ClearErrorContext(&espeak_context);
+ return nullptr;
+ }
+ espeak_ng_InitializeOutput(ENOUTPUT_MODE_SYNCHRONOUS, 0, nullptr);
}

- auto *synth = new piper_synthesizer();
+ std::unique_ptr<piper_synthesizer> synth(new piper_synthesizer());
synth->phoneme_type = phoneme_type;

// Load config options
@@ -280,7 +288,7 @@ auto piper_create_with_options(const piper_create_options *options)
synth->session = std::make_unique<Ort::Session>(
Ort::Session(ort_env, model_path_ort, synth->session_options));

- return synth;
+ return synth.release();
}

auto piper_create(const char *model_path, const char *config_path,
Loading