summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--audio/Makefile1
-rw-r--r--audio/piper/Makefile27
-rw-r--r--audio/piper/distinfo3
-rw-r--r--audio/piper/files/patch-CMakeLists.txt139
-rw-r--r--audio/piper/files/patch-src_cpp_piper.cpp61
-rw-r--r--audio/piper/pkg-descr2
6 files changed, 233 insertions, 0 deletions
diff --git a/audio/Makefile b/audio/Makefile
index bcfe68ef060c..ca57669e1928 100644
--- a/audio/Makefile
+++ b/audio/Makefile
@@ -594,6 +594,7 @@
SUBDIR += pianod2
SUBDIR += picard
SUBDIR += picard-plugins
+ SUBDIR += piper
SUBDIR += piper-phonemize
SUBDIR += pipewire-module-xrdp
SUBDIR += pipewire-spa-oss
diff --git a/audio/piper/Makefile b/audio/piper/Makefile
new file mode 100644
index 000000000000..c13f0322cc28
--- /dev/null
+++ b/audio/piper/Makefile
@@ -0,0 +1,27 @@
+PORTNAME= piper
+DISTVERSION= 2023.11.14
+DISTVERSIONSUFFIX= -2
+CATEGORIES= audio
+
+MAINTAINER= kenrap@kennethraplee.com
+COMMENT= Fast, local text to speech system
+WWW= https://rhasspy.github.io/piper-samples/
+
+LICENSE= MIT
+LICENSE_FILE= ${WRKSRC}/LICENSE.md
+
+LIB_DEPENDS= libespeak-ng.so:audio/espeak-ng \
+ libfmt.so:devel/libfmt \
+ libonnxruntime.so:misc/onnxruntime \
+ libpiper_phonemize.so:audio/piper-phonemize \
+ libspdlog.so:devel/spdlog
+
+USES= compiler:c++17-lang cmake localbase pkgconfig tar:xz xorg
+USE_XORG= x11
+
+USE_GITHUB= yes
+GH_ACCOUNT= rhasspy
+
+PLIST_FILES= bin/piper
+
+.include <bsd.port.mk>
diff --git a/audio/piper/distinfo b/audio/piper/distinfo
new file mode 100644
index 000000000000..9f8fb736b6a0
--- /dev/null
+++ b/audio/piper/distinfo
@@ -0,0 +1,3 @@
+TIMESTAMP = 1750142677
+SHA256 (rhasspy-piper-2023.11.14-2_GH0.tar.gz) = 8b684e102cfe23af097830db9555a8641f17735725853c531a1daeb34b6ed1a8
+SIZE (rhasspy-piper-2023.11.14-2_GH0.tar.gz) = 25602353
diff --git a/audio/piper/files/patch-CMakeLists.txt b/audio/piper/files/patch-CMakeLists.txt
new file mode 100644
index 000000000000..8c8041a0c750
--- /dev/null
+++ b/audio/piper/files/patch-CMakeLists.txt
@@ -0,0 +1,139 @@
+--- CMakeLists.txt.orig 2023-11-14 17:55:22 UTC
++++ CMakeLists.txt
+@@ -13,7 +13,7 @@ if(MSVC)
+ add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/utf-8>")
+ elseif(NOT APPLE)
+ # Linux flags
+- string(APPEND CMAKE_CXX_FLAGS " -Wall -Wextra -Wl,-rpath,'$ORIGIN'")
++ string(APPEND CMAKE_CXX_FLAGS " -Wall -Wextra")
+ string(APPEND CMAKE_C_FLAGS " -Wall -Wextra")
+ endif()
+
+@@ -25,7 +25,7 @@ add_executable(test_piper src/cpp/test.cpp src/cpp/piper.cpp)
+
+ # ---- fmt ---
+
+-if(NOT DEFINED FMT_DIR)
++if(FALSE)
+ set(FMT_VERSION "10.0.0")
+ set(FMT_DIR "${CMAKE_CURRENT_BINARY_DIR}/fi")
+
+@@ -43,7 +43,7 @@ endif()
+
+ # ---- spdlog ---
+
+-if(NOT DEFINED SPDLOG_DIR)
++if(FALSE)
+ set(SPDLOG_DIR "${CMAKE_CURRENT_BINARY_DIR}/si")
+ set(SPDLOG_VERSION "1.12.0")
+ ExternalProject_Add(
+@@ -58,7 +58,13 @@ endif()
+
+ # ---- piper-phonemize ---
+
+-if(NOT DEFINED PIPER_PHONEMIZE_DIR)
++find_package(PkgConfig)
++pkg_check_modules(FMT REQUIRED fmt)
++pkg_check_modules(ONNXRUNTIME REQUIRED libonnxruntime)
++pkg_check_modules(PIPER_PHONEMIZE REQUIRED piper_phonemize)
++pkg_check_modules(SPDLOG REQUIRED spdlog)
++
++if(FALSE)
+ set(PIPER_PHONEMIZE_DIR "${CMAKE_CURRENT_BINARY_DIR}/pi")
+ ExternalProject_Add(
+ piper_phonemize_external
+@@ -74,9 +80,8 @@ endif()
+
+ if((NOT MSVC) AND (NOT APPLE))
+ # Linux flags
+- string(APPEND CMAKE_CXX_FLAGS " -Wall -Wextra -Wl,-rpath,'$ORIGIN'")
++ string(APPEND CMAKE_CXX_FLAGS " -Wall -Wextra")
+ string(APPEND CMAKE_C_FLAGS " -Wall -Wextra")
+- target_link_libraries(piper -static-libgcc -static-libstdc++)
+
+ set(PIPER_EXTRA_LIBRARIES "pthread")
+ endif()
+@@ -91,18 +96,18 @@ target_link_libraries(piper
+ )
+
+ target_link_directories(piper PUBLIC
+- ${FMT_DIR}/lib
+- ${SPDLOG_DIR}/lib
+- ${PIPER_PHONEMIZE_DIR}/lib
++ ${FMT_LIBRARY_DIRS}
++ ${SPDLOG_LIBRARY_DIRS}
++ ${ONNXRUNTIME_LIBRARY_DIRS}
+ )
+
+ target_include_directories(piper PUBLIC
+- ${FMT_DIR}/include
+- ${SPDLOG_DIR}/include
+- ${PIPER_PHONEMIZE_DIR}/include
++ ${FMT_INCLUDE_DIRS}
++ ${SPDLOG_INCLUDE_DIRS}
++ ${ONNXRUNTIME_INCLUDE_DIRS}
+ )
+
+-target_compile_definitions(piper PUBLIC _PIPER_VERSION=${piper_version})
++target_compile_definitions(piper PUBLIC _PIPER_VERSION="${piper_version}")
+
+ # ---- Declare test ----
+ include(CTest)
+@@ -116,16 +121,16 @@ target_compile_features(test_piper PUBLIC cxx_std_17)
+
+ target_include_directories(
+ test_piper PUBLIC
+- ${FMT_DIR}/include
+- ${SPDLOG_DIR}/include
+- ${PIPER_PHONEMIZE_DIR}/include
++ ${FMT_INCLUDE_DIRS}
++ ${SPDLOG_INCLUDE_DIRS}
++ ${ONNXRUNTIME_INCLUDE_DIRS}
+ )
+
+ target_link_directories(
+ test_piper PUBLIC
+- ${FMT_DIR}/lib
+- ${SPDLOG_DIR}/lib
+- ${PIPER_PHONEMIZE_DIR}/lib
++ ${FMT_LIBRARY_DIRS}
++ ${SPDLOG_LIBRARY_DIRS}
++ ${ONNXRUNTIME_LIBRARY_DIRS}
+ )
+
+ target_link_libraries(test_piper PUBLIC
+@@ -140,33 +145,5 @@ target_link_libraries(test_piper PUBLIC
+
+ install(
+ TARGETS piper
+- DESTINATION ${CMAKE_INSTALL_PREFIX})
+-
+-# Dependencies
+-install(
+- DIRECTORY ${PIPER_PHONEMIZE_DIR}/bin/
+- DESTINATION ${CMAKE_INSTALL_PREFIX}
+- USE_SOURCE_PERMISSIONS # keep +x
+- FILES_MATCHING
+- PATTERN "piper_phonemize"
+- PATTERN "espeak-ng"
+- PATTERN "*.dll"
+-)
+-
+-install(
+- DIRECTORY ${PIPER_PHONEMIZE_DIR}/lib/
+- DESTINATION ${CMAKE_INSTALL_PREFIX}
+- FILES_MATCHING
+- PATTERN "*.dll"
+- PATTERN "*.so*"
+-)
+-
+-install(
+- DIRECTORY ${PIPER_PHONEMIZE_DIR}/share/espeak-ng-data
+- DESTINATION ${CMAKE_INSTALL_PREFIX}
+-)
+-
+-install(
+- FILES ${PIPER_PHONEMIZE_DIR}/share/libtashkeel_model.ort
+- DESTINATION ${CMAKE_INSTALL_PREFIX}
++ DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
+ )
diff --git a/audio/piper/files/patch-src_cpp_piper.cpp b/audio/piper/files/patch-src_cpp_piper.cpp
new file mode 100644
index 000000000000..51f672629560
--- /dev/null
+++ b/audio/piper/files/patch-src_cpp_piper.cpp
@@ -0,0 +1,61 @@
+--- src/cpp/piper.cpp.orig
++++ src/cpp/piper.cpp
+@@ -6,7 +6,7 @@
+ #include <stdexcept>
+
+ #include <espeak-ng/speak_lib.h>
+-#include <onnxruntime_cxx_api.h>
++#include <onnxruntime/onnxruntime_cxx_api.h>
+ #include <spdlog/spdlog.h>
+
+ #include "json.hpp"
+@@ -229,22 +229,6 @@ void initialize(PiperConfig &config) {
+ spdlog::debug("Initialized eSpeak");
+ }
+
+- // Load onnx model for libtashkeel
+- // https://github.com/mush42/libtashkeel/
+- if (config.useTashkeel) {
+- spdlog::debug("Using libtashkeel for diacritization");
+- if (!config.tashkeelModelPath) {
+- throw std::runtime_error("No path to libtashkeel model");
+- }
+-
+- spdlog::debug("Loading libtashkeel model from {}",
+- config.tashkeelModelPath.value());
+- config.tashkeelState = std::make_unique<tashkeel::State>();
+- tashkeel::tashkeel_load(config.tashkeelModelPath.value(),
+- *config.tashkeelState);
+- spdlog::debug("Initialized libtashkeel");
+- }
+-
+ spdlog::info("Initialized piper");
+ }
+
+@@ -447,15 +431,6 @@ void textToAudio(PiperConfig &config, Voice &voice, std::string text,
+ voice.synthesisConfig.sampleRate * voice.synthesisConfig.channels);
+ }
+
+- if (config.useTashkeel) {
+- if (!config.tashkeelState) {
+- throw std::runtime_error("Tashkeel model is not loaded");
+- }
+-
+- spdlog::debug("Diacritizing text with libtashkeel: {}", text);
+- text = tashkeel::tashkeel_run(text, *config.tashkeelState);
+- }
+-
+ // Phonemes for each sentence
+ spdlog::debug("Phonemizing text: {}", text);
+ std::vector<std::vector<Phoneme>> phonemes;
+--- src/cpp/piper.hpp.orig
++++ src/cpp/piper.hpp
+@@ -8,7 +8,7 @@
+ #include <string>
+ #include <vector>
+
+-#include <onnxruntime_cxx_api.h>
++#include <onnxruntime/onnxruntime_cxx_api.h>
+ #include <piper-phonemize/phoneme_ids.hpp>
+ #include <piper-phonemize/phonemize.hpp>
+ #include <piper-phonemize/tashkeel.hpp>
diff --git a/audio/piper/pkg-descr b/audio/piper/pkg-descr
new file mode 100644
index 000000000000..cad20f548b02
--- /dev/null
+++ b/audio/piper/pkg-descr
@@ -0,0 +1,2 @@
+A fast, local neural text to speech system that sounds great and is optimized
+for the Raspberry Pi 4. Piper is used in a variety of projects.