mirror of
https://gitlab.alpinelinux.org/alpine/aports.git
synced 2025-04-12 16:06:42 +02:00
110 lines
3.6 KiB
Diff
110 lines
3.6 KiB
Diff
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
|
index b1562a1..4de504c 100644
|
|
--- a/CMakeLists.txt
|
|
+++ b/CMakeLists.txt
|
|
@@ -97,7 +97,10 @@ endif()
|
|
|
|
# ---- espeak-ng ---
|
|
|
|
-if(NOT DEFINED ESPEAK_NG_DIR)
|
|
+find_package(PkgConfig)
|
|
+pkg_check_modules(ESPEAK_NG REQUIRED espeak-ng<2)
|
|
+
|
|
+if(FALSE)
|
|
set(ESPEAK_NG_DIR "${CMAKE_CURRENT_BINARY_DIR}/ei")
|
|
|
|
include(ExternalProject)
|
|
@@ -125,13 +128,11 @@ endif()
|
|
target_include_directories(
|
|
piper_phonemize PUBLIC
|
|
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src>"
|
|
- ${ESPEAK_NG_DIR}/include
|
|
${ONNXRUNTIME_DIR}/include
|
|
)
|
|
|
|
target_link_directories(
|
|
piper_phonemize PUBLIC
|
|
- ${ESPEAK_NG_DIR}/lib
|
|
${ONNXRUNTIME_DIR}/lib
|
|
)
|
|
|
|
@@ -221,16 +221,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/src/phonemize.cpp b/src/phonemize.cpp
|
|
index 28b01e4..a5b748a 100644
|
|
--- a/src/phonemize.cpp
|
|
+++ b/src/phonemize.cpp
|
|
@@ -35,14 +35,21 @@ void phonemize_eSpeak(std::string text, eSpeakPhonemeConfig &config,
|
|
|
|
std::vector<Phoneme> *sentencePhonemes = nullptr;
|
|
const char *inputTextPointer = textCopy.c_str();
|
|
- int terminator = 0;
|
|
|
|
while (inputTextPointer != NULL) {
|
|
- // Modified espeak-ng API to get access to clause terminator
|
|
- std::string clausePhonemes(espeak_TextToPhonemesWithTerminator(
|
|
+ int terminator = 0;
|
|
+ std::string clausePhonemes(espeak_TextToPhonemes(
|
|
(const void **)&inputTextPointer,
|
|
/*textmode*/ espeakCHARS_AUTO,
|
|
- /*phonememode = IPA*/ 0x02, &terminator));
|
|
+ /*phonememode = IPA*/ 0x02));
|
|
+
|
|
+ const char *remainingTextPointer = inputTextPointer ? inputTextPointer : textCopy.c_str()+textCopy.length()+1;
|
|
+ for (size_t i = -2; remainingTextPointer+i > textCopy.c_str(); i--) {
|
|
+ if ((remainingTextPointer[i]) != ' ') {
|
|
+ terminator = remainingTextPointer[i];
|
|
+ break;
|
|
+ }
|
|
+ }
|
|
|
|
// Decompose, e.g. "ç" -> "c" + "̧"
|
|
auto phonemesNorm = una::norm::to_nfd_utf8(clausePhonemes);
|
|
@@ -105,25 +112,24 @@ void phonemize_eSpeak(std::string text, eSpeakPhonemeConfig &config,
|
|
}
|
|
|
|
// Add appropriate punctuation depending on terminator type
|
|
- int punctuation = terminator & 0x000FFFFF;
|
|
- if (punctuation == CLAUSE_PERIOD) {
|
|
+ if (terminator == '.') {
|
|
sentencePhonemes->push_back(config.period);
|
|
- } else if (punctuation == CLAUSE_QUESTION) {
|
|
+ } else if (terminator == '?') {
|
|
sentencePhonemes->push_back(config.question);
|
|
- } else if (punctuation == CLAUSE_EXCLAMATION) {
|
|
+ } else if (terminator == '!') {
|
|
sentencePhonemes->push_back(config.exclamation);
|
|
- } else if (punctuation == CLAUSE_COMMA) {
|
|
+ } else if (terminator == ',') {
|
|
sentencePhonemes->push_back(config.comma);
|
|
sentencePhonemes->push_back(config.space);
|
|
- } else if (punctuation == CLAUSE_COLON) {
|
|
+ } else if (terminator == ':') {
|
|
sentencePhonemes->push_back(config.colon);
|
|
sentencePhonemes->push_back(config.space);
|
|
- } else if (punctuation == CLAUSE_SEMICOLON) {
|
|
+ } else if (terminator == ';') {
|
|
sentencePhonemes->push_back(config.semicolon);
|
|
sentencePhonemes->push_back(config.space);
|
|
}
|
|
|
|
- if ((terminator & CLAUSE_TYPE_SENTENCE) == CLAUSE_TYPE_SENTENCE) {
|
|
+ if (terminator == '.' || terminator == '?' || terminator == '!') {
|
|
// End of sentence
|
|
sentencePhonemes = nullptr;
|
|
}
|