summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenneth Raplee <kenrap@kennethraplee.com>2025-06-06 03:31:23 -0700
committerGleb Popov <arrowd@FreeBSD.org>2025-06-17 10:27:55 +0300
commit945407e8ec887aa1241eb2d060b5bdfe0ffc2e48 (patch)
treed4282bd0e5704b6a2410f1abff7d214435a4a9b7
parentsecurity/vuxml: add www/*chromium < 137.0.7151.103 (diff)
audio/piper-phonemize: Converts text to phonemes for Piper
Pull Request: https://github.com/freebsd/freebsd-ports/pull/406 Co-authored-by: Gleb Popov <arrowd@FreeBSD.org>
-rw-r--r--audio/Makefile1
-rw-r--r--audio/piper-phonemize/Makefile28
-rw-r--r--audio/piper-phonemize/distinfo3
-rw-r--r--audio/piper-phonemize/files/patch-CMakeLists.txt132
-rw-r--r--audio/piper-phonemize/files/piper_phonemize.pc.in11
-rw-r--r--audio/piper-phonemize/pkg-descr5
-rw-r--r--audio/piper-phonemize/pkg-plist12
7 files changed, 192 insertions, 0 deletions
diff --git a/audio/Makefile b/audio/Makefile
index bd42f99545e6..bcfe68ef060c 100644
--- a/audio/Makefile
+++ b/audio/Makefile
@@ -594,6 +594,7 @@
SUBDIR += pianod2
SUBDIR += picard
SUBDIR += picard-plugins
+ SUBDIR += piper-phonemize
SUBDIR += pipewire-module-xrdp
SUBDIR += pipewire-spa-oss
SUBDIR += pithos
diff --git a/audio/piper-phonemize/Makefile b/audio/piper-phonemize/Makefile
new file mode 100644
index 000000000000..47bf717c984c
--- /dev/null
+++ b/audio/piper-phonemize/Makefile
@@ -0,0 +1,28 @@
+PORTNAME= piper-phonemize
+DISTVERSION= 2023.11.14
+DISTVERSIONSUFFIX= -4
+CATEGORIES= audio
+
+MAINTAINER= kenrap@kennethraplee.com
+COMMENT= Fast, local neural 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 \
+ libonnxruntime.so:misc/onnxruntime
+
+USES= compiler:c++17-lang cmake pkgconfig tar:xz
+
+USE_GITHUB= yes
+GH_ACCOUNT= rhasspy
+
+CMAKE_ARGS= -DESPEAK_NG_DIR=${LOCALBASE} \
+ -DONNXRUNTIME_DIR=${LOCALBASE}
+
+post-stage:
+ ${SED} -e 's|%%PREFIX%%|${PREFIX}|' ${FILESDIR}/piper_phonemize.pc.in \
+ > ${STAGEDIR}${PREFIX}/libdata/pkgconfig/piper_phonemize.pc
+
+.include <bsd.port.mk>
diff --git a/audio/piper-phonemize/distinfo b/audio/piper-phonemize/distinfo
new file mode 100644
index 000000000000..dbd7efc6acde
--- /dev/null
+++ b/audio/piper-phonemize/distinfo
@@ -0,0 +1,3 @@
+TIMESTAMP = 1748849594
+SHA256 (rhasspy-piper-phonemize-2023.11.14-4_GH0.tar.gz) = 4713d62b9d639d9e27c9abb6dcc5f98ee36c9b873ae0590644d325837ebf135a
+SIZE (rhasspy-piper-phonemize-2023.11.14-4_GH0.tar.gz) = 9788151
diff --git a/audio/piper-phonemize/files/patch-CMakeLists.txt b/audio/piper-phonemize/files/patch-CMakeLists.txt
new file mode 100644
index 000000000000..f4ae844b908b
--- /dev/null
+++ b/audio/piper-phonemize/files/patch-CMakeLists.txt
@@ -0,0 +1,132 @@
+https://github.com/rhasspy/piper-phonemize/pull/31
+
+--- CMakeLists.txt.orig 2023-11-14 17:54:34 UTC
++++ CMakeLists.txt
+@@ -17,7 +17,7 @@ elseif(NOT APPLE)
+
+ 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()
+
+@@ -34,100 +34,13 @@ set_target_properties(piper_phonemize PROPERTIES
+ SOVERSION ${PROJECT_VERSION_MAJOR}
+ )
+
+-# ---- onnxruntime ---
+-
+-# Look for onnxruntime files in <root>/lib
+-if(NOT DEFINED ONNXRUNTIME_DIR)
+- if(NOT DEFINED ONNXRUNTIME_VERSION)
+- set(ONNXRUNTIME_VERSION "1.14.1")
+- endif()
+-
+- if(WIN32)
+- # Windows x86-64
+- set(ONNXRUNTIME_PREFIX "onnxruntime-win-x64-${ONNXRUNTIME_VERSION}")
+- set(ONNXRUNTIME_EXT "zip")
+- elseif (APPLE)
+- if(CMAKE_SYSTEM_PROCESSOR STREQUAL x86_64)
+- # MacOS x86-64
+- set(ONNXRUNTIME_PREFIX "onnxruntime-osx-x86_64-${ONNXRUNTIME_VERSION}")
+- elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL arm64)
+- # MacOS Apple Silicon
+- set(ONNXRUNTIME_PREFIX "onnxruntime-osx-arm64-${ONNXRUNTIME_VERSION}")
+- else()
+- message(FATAL_ERROR "Unsupported architecture for onnxruntime")
+- endif()
+-
+- set(ONNXRUNTIME_EXT "tgz")
+- else()
+- if(CMAKE_SYSTEM_PROCESSOR STREQUAL x86_64)
+- # Linux x86-64
+- set(ONNXRUNTIME_PREFIX "onnxruntime-linux-x64-${ONNXRUNTIME_VERSION}")
+- elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL aarch64)
+- # Linux ARM 64-bit
+- set(ONNXRUNTIME_PREFIX "onnxruntime-linux-aarch64-${ONNXRUNTIME_VERSION}")
+- elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL armv7l)
+- # Linux ARM 32-bit
+- set(ONNXRUNTIME_PREFIX "onnxruntime-linux-arm32-${ONNXRUNTIME_VERSION}")
+- set(ONNXRUNTIME_URL "https://github.com/synesthesiam/prebuilt-apps/releases/download/v1.0/onnxruntime-linux-arm32-${ONNXRUNTIME_VERSION}.tgz")
+- else()
+- message(FATAL_ERROR "Unsupported architecture for onnxruntime")
+- endif()
+-
+- set(ONNXRUNTIME_EXT "tgz")
+- endif()
+-
+- if(NOT DEFINED ONNXRUNTIME_URL)
+- set(ONNXRUNTIME_URL "https://github.com/microsoft/onnxruntime/releases/download/v${ONNXRUNTIME_VERSION}/${ONNXRUNTIME_PREFIX}.${ONNXRUNTIME_EXT}")
+- endif()
+-
+- set(ONNXRUNTIME_FILENAME "${ONNXRUNTIME_PREFIX}.${ONNXRUNTIME_EXT}")
+- set(ONNXRUNTIME_DIR "${CMAKE_CURRENT_LIST_DIR}/lib/${ONNXRUNTIME_PREFIX}")
+-
+- if(NOT EXISTS "${ONNXRUNTIME_DIR}")
+- if(NOT EXISTS "download/${ONNXRUNTIME_FILENAME}")
+- # Download onnxruntime release
+- message("Downloading ${ONNXRUNTIME_URL}")
+- file(DOWNLOAD "${ONNXRUNTIME_URL}" "download/${ONNXRUNTIME_FILENAME}")
+- endif()
+-
+- # Extract .zip or .tgz to a directory like lib/onnxruntime-linux-x64-1.14.1/
+- file(ARCHIVE_EXTRACT INPUT "download/${ONNXRUNTIME_FILENAME}" DESTINATION "${CMAKE_CURRENT_LIST_DIR}/lib")
+- endif()
+-endif()
+-
+-# ---- espeak-ng ---
+-
+-if(NOT DEFINED ESPEAK_NG_DIR)
+- set(ESPEAK_NG_DIR "${CMAKE_CURRENT_BINARY_DIR}/ei")
+-
+- include(ExternalProject)
+- ExternalProject_Add(
+- espeak_ng_external
+- PREFIX "${CMAKE_CURRENT_BINARY_DIR}/e"
+- URL "https://github.com/rhasspy/espeak-ng/archive/refs/heads/master.zip"
+- CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${ESPEAK_NG_DIR}
+- CMAKE_ARGS -DUSE_ASYNC:BOOL=OFF
+- CMAKE_ARGS -DBUILD_SHARED_LIBS:BOOL=ON
+- CMAKE_ARGS -DUSE_MBROLA:BOOL=OFF
+- CMAKE_ARGS -DUSE_LIBSONIC:BOOL=OFF
+- CMAKE_ARGS -DUSE_LIBPCAUDIO:BOOL=OFF
+- CMAKE_ARGS -DUSE_KLATT:BOOL=OFF
+- CMAKE_ARGS -DUSE_SPEECHPLAYER:BOOL=OFF
+- CMAKE_ARGS -DEXTRA_cmn:BOOL=ON
+- CMAKE_ARGS -DEXTRA_ru:BOOL=ON
+- CMAKE_ARGS -DCMAKE_C_FLAGS="-D_FILE_OFFSET_BITS=64"
+- )
+- add_dependencies(piper_phonemize espeak_ng_external)
+-endif()
+-
+-
+ # ---- Declare library ----
+
+ target_include_directories(
+ piper_phonemize PUBLIC
+ "$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src>"
+ ${ESPEAK_NG_DIR}/include
+- ${ONNXRUNTIME_DIR}/include
++ ${ONNXRUNTIME_DIR}/include/onnxruntime
+ )
+
+ target_link_directories(
+@@ -220,16 +133,3 @@ install(
+ install(
+ FILES ${CMAKE_SOURCE_DIR}/etc/libtashkeel_model.ort
+ TYPE DATA)
+-
+-# Dependencies
+-install(
+- DIRECTORY ${ESPEAK_NG_DIR}/
+- DESTINATION ${CMAKE_INSTALL_PREFIX})
+-
+-install(
+- DIRECTORY ${ONNXRUNTIME_DIR}/include/
+- DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
+-
+-install(
+- DIRECTORY ${ONNXRUNTIME_DIR}/lib/
+- DESTINATION ${CMAKE_INSTALL_LIBDIR})
diff --git a/audio/piper-phonemize/files/piper_phonemize.pc.in b/audio/piper-phonemize/files/piper_phonemize.pc.in
new file mode 100644
index 000000000000..6927d4db2462
--- /dev/null
+++ b/audio/piper-phonemize/files/piper_phonemize.pc.in
@@ -0,0 +1,11 @@
+prefix=%%PREFIX%%
+bindir=${prefix}/bin
+libdir=${prefix}/lib
+includedir=${prefix}/include/piper-phonemize
+
+Name: piper-phonemize
+Description: Piper Phonemization Library
+URL: https://github.com/rhasspy/piper-phonemize
+Version: 2023.11.14-4
+Libs: -L${libdir} -lpiper_phonemize
+Cflags: -I${includedir}
diff --git a/audio/piper-phonemize/pkg-descr b/audio/piper-phonemize/pkg-descr
new file mode 100644
index 000000000000..c78947a4a16f
--- /dev/null
+++ b/audio/piper-phonemize/pkg-descr
@@ -0,0 +1,5 @@
+Converts text to phonemes for Piper.
+
+Uses eSpeak phonemes with the espeak_TextToPhonemesWithTerminator function.
+This function allows for Piper to preserve punctuation and detect sentence
+boundaries.
diff --git a/audio/piper-phonemize/pkg-plist b/audio/piper-phonemize/pkg-plist
new file mode 100644
index 000000000000..f4e55dbd4bd3
--- /dev/null
+++ b/audio/piper-phonemize/pkg-plist
@@ -0,0 +1,12 @@
+bin/piper_phonemize
+include/piper-phonemize/json.hpp
+include/piper-phonemize/phoneme_ids.hpp
+include/piper-phonemize/phonemize.hpp
+include/piper-phonemize/shared.hpp
+include/piper-phonemize/tashkeel.hpp
+include/piper-phonemize/uni_algo.h
+lib/libpiper_phonemize.so
+lib/libpiper_phonemize.so.1
+lib/libpiper_phonemize.so.1.2.0
+libdata/pkgconfig/piper_phonemize.pc
+share/libtashkeel_model.ort