mirror of
https://github.com/pstrueb/piper.git
synced 2026-07-14 12:00:49 +00:00
Use RPATH in docker build
This commit is contained in:
+27
-7
@@ -12,13 +12,25 @@ RUN --mount=type=cache,id=apt-build,target=/var/cache/apt \
|
|||||||
apt-get update && \
|
apt-get update && \
|
||||||
apt-get install --yes --no-install-recommends \
|
apt-get install --yes --no-install-recommends \
|
||||||
build-essential \
|
build-essential \
|
||||||
cmake \
|
autoconf automake libtool pkg-config cmake
|
||||||
pkg-config \
|
|
||||||
libespeak-ng-dev \
|
|
||||||
libpcaudio-dev
|
|
||||||
|
|
||||||
WORKDIR /build
|
WORKDIR /build
|
||||||
|
|
||||||
|
# Build minimal version of espeak-ng
|
||||||
|
ADD lib/espeak-ng-1.51.tar.gz ./
|
||||||
|
RUN cd espeak-ng-1.51 && \
|
||||||
|
./autogen.sh && \
|
||||||
|
./configure \
|
||||||
|
--without-pcaudiolib \
|
||||||
|
--without-klatt \
|
||||||
|
--without-speechplayer \
|
||||||
|
--without-mbrola \
|
||||||
|
--without-sonic \
|
||||||
|
--prefix=/usr && \
|
||||||
|
make -j8 src/espeak-ng src/speak-ng && \
|
||||||
|
make && \
|
||||||
|
make install
|
||||||
|
|
||||||
# Copy onnxruntime library
|
# Copy onnxruntime library
|
||||||
COPY lib/ ./lib/
|
COPY lib/ ./lib/
|
||||||
RUN mkdir -p /usr/local/include/onnxruntime && \
|
RUN mkdir -p /usr/local/include/onnxruntime && \
|
||||||
@@ -29,11 +41,19 @@ RUN mkdir -p /usr/local/include/onnxruntime && \
|
|||||||
# Build larynx binary
|
# Build larynx binary
|
||||||
COPY Makefile ./
|
COPY Makefile ./
|
||||||
COPY src/cpp/ ./src/cpp/
|
COPY src/cpp/ ./src/cpp/
|
||||||
RUN make release
|
RUN make no-pcaudio
|
||||||
|
|
||||||
|
# Build .tar.gz to keep symlinks
|
||||||
|
WORKDIR /dist
|
||||||
|
RUN mkdir -p larynx && \
|
||||||
|
cp -d /usr/lib/libespeak-ng.so* ./larynx/ && \
|
||||||
|
cp -dR /usr/share/espeak-ng-data ./larynx/ && \
|
||||||
|
cp -d /usr/local/include/onnxruntime/lib/libonnxruntime.so.* ./larynx/ && \
|
||||||
|
cp /build/build/larynx ./larynx/ && \
|
||||||
|
tar -czf larynx.tar.gz larynx/
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
|
|
||||||
FROM scratch
|
FROM scratch
|
||||||
|
|
||||||
COPY --from=build /usr/local/include/onnxruntime/lib/libonnxruntime.so.* ./
|
COPY --from=build /dist/larynx.tar.gz ./
|
||||||
COPY --from=build /build/build/larynx ./
|
|
||||||
|
|||||||
Binary file not shown.
@@ -9,7 +9,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|||||||
|
|
||||||
ADD_EXECUTABLE(larynx main.cpp)
|
ADD_EXECUTABLE(larynx main.cpp)
|
||||||
|
|
||||||
string(APPEND CMAKE_CXX_FLAGS " -Wall -Wextra")
|
string(APPEND CMAKE_CXX_FLAGS " -Wall -Wextra -Wl,-rpath,'$ORIGIN'")
|
||||||
string(APPEND CMAKE_C_FLAGS " -Wall -Wextra")
|
string(APPEND CMAKE_C_FLAGS " -Wall -Wextra")
|
||||||
|
|
||||||
find_package(PkgConfig)
|
find_package(PkgConfig)
|
||||||
@@ -30,10 +30,12 @@ set(ONNXRUNTIME_ROOTDIR "/usr/local/include/onnxruntime")
|
|||||||
|
|
||||||
target_link_libraries(larynx
|
target_link_libraries(larynx
|
||||||
onnxruntime
|
onnxruntime
|
||||||
|
-static-libgcc -static-libstdc++
|
||||||
${ESPEAK_NG_LIBRARIES}
|
${ESPEAK_NG_LIBRARIES}
|
||||||
${PCAUDIO_LIBRARIES})
|
${PCAUDIO_LIBRARIES})
|
||||||
|
|
||||||
target_link_directories(larynx PUBLIC
|
target_link_directories(larynx PUBLIC
|
||||||
|
${ESPEAK_NG_LIBRARY_DIRS}
|
||||||
${ONNXRUNTIME_ROOTDIR}/lib)
|
${ONNXRUNTIME_ROOTDIR}/lib)
|
||||||
|
|
||||||
target_include_directories(larynx PUBLIC
|
target_include_directories(larynx PUBLIC
|
||||||
|
|||||||
+10
-2
@@ -1,6 +1,7 @@
|
|||||||
#ifndef LARYNX_H_
|
#ifndef LARYNX_H_
|
||||||
#define LARYNX_H_
|
#define LARYNX_H_
|
||||||
|
|
||||||
|
#include <filesystem>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@@ -26,11 +27,18 @@ struct Voice {
|
|||||||
ModelSession session;
|
ModelSession session;
|
||||||
};
|
};
|
||||||
|
|
||||||
void initialize() {
|
void initialize(std::filesystem::path cwd) {
|
||||||
|
const char *dataPath = NULL;
|
||||||
|
|
||||||
|
auto cwdDataPath = cwd.append("espeak-ng-data");
|
||||||
|
if (std::filesystem::is_directory(cwdDataPath)) {
|
||||||
|
dataPath = cwdDataPath.c_str();
|
||||||
|
}
|
||||||
|
|
||||||
// Set up espeak-ng for calling espeak_TextToPhonemes
|
// Set up espeak-ng for calling espeak_TextToPhonemes
|
||||||
int result = espeak_Initialize(AUDIO_OUTPUT_SYNCHRONOUS,
|
int result = espeak_Initialize(AUDIO_OUTPUT_SYNCHRONOUS,
|
||||||
/*buflength*/ 0,
|
/*buflength*/ 0,
|
||||||
/*path*/ NULL,
|
/*path*/ dataPath,
|
||||||
/*options*/ 0);
|
/*options*/ 0);
|
||||||
if (result < 0) {
|
if (result < 0) {
|
||||||
throw runtime_error("Failed to initialize eSpeak-ng");
|
throw runtime_error("Failed to initialize eSpeak-ng");
|
||||||
|
|||||||
+2
-1
@@ -35,7 +35,8 @@ int main(int argc, char *argv[]) {
|
|||||||
RunConfig runConfig;
|
RunConfig runConfig;
|
||||||
parseArgs(argc, argv, runConfig);
|
parseArgs(argc, argv, runConfig);
|
||||||
|
|
||||||
larynx::initialize();
|
auto exePath = filesystem::path(argv[0]);
|
||||||
|
larynx::initialize(exePath.parent_path());
|
||||||
|
|
||||||
larynx::Voice voice;
|
larynx::Voice voice;
|
||||||
auto startTime = chrono::steady_clock::now();
|
auto startTime = chrono::steady_clock::now();
|
||||||
|
|||||||
Reference in New Issue
Block a user