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>
This commit is contained in:
Kenneth Raplee
2025-06-17 10:27:55 +03:00
committed by Gleb Popov
parent 1c919c5a34
commit 945407e8ec
7 changed files with 192 additions and 0 deletions
+1
View File
@@ -594,6 +594,7 @@
SUBDIR += pianod2
SUBDIR += picard
SUBDIR += picard-plugins
SUBDIR += piper-phonemize
SUBDIR += pipewire-module-xrdp
SUBDIR += pipewire-spa-oss
SUBDIR += pithos
+28
View File
@@ -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>
+3
View File
@@ -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
@@ -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})
@@ -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}
+5
View File
@@ -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.
+12
View File
@@ -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