From 4b332e80d0d21c088aca35134148cfc35b4f4c36 Mon Sep 17 00:00:00 2001 From: Fangjun Kuang Date: Sun, 26 Nov 2023 23:41:26 +0800 Subject: [PATCH 1/8] Support building shared library of ucd --- src/ucd-tools/CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ucd-tools/CMakeLists.txt b/src/ucd-tools/CMakeLists.txt index 2050c114aa..817e595fad 100644 --- a/src/ucd-tools/CMakeLists.txt +++ b/src/ucd-tools/CMakeLists.txt @@ -1,4 +1,4 @@ -add_library(ucd STATIC +add_library(ucd src/case.c src/categories.c src/ctype.c @@ -7,3 +7,5 @@ add_library(ucd STATIC src/tostring.c ) target_include_directories(ucd PUBLIC src/include) + +install(TARGETS ucd) From 29cb7884488f42e18346221d082edb85b37a2bf3 Mon Sep 17 00:00:00 2001 From: Fangjun Kuang Date: Mon, 27 Nov 2023 16:10:22 +0800 Subject: [PATCH 2/8] Don't redefine tolower and toupper. --- src/include/compat/wctype.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/include/compat/wctype.h b/src/include/compat/wctype.h index e0d2c64ee3..4cdc9d920e 100644 --- a/src/include/compat/wctype.h +++ b/src/include/compat/wctype.h @@ -44,7 +44,7 @@ #define iswspace ucd_isspace #define iswupper ucd_isupper #define iswxdigit ucd_isxdigit -#define tolower ucd_tolower -#define toupper udc_toupper +// #define tolower ucd_tolower +// #define toupper udc_toupper #endif From 74d33b85ee46b1891dc50c0b1b5c3d200478789f Mon Sep 17 00:00:00 2001 From: Fangjun Kuang Date: Mon, 27 Nov 2023 18:50:33 +0800 Subject: [PATCH 3/8] Fix building on Windows --- cmake/data.cmake | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cmake/data.cmake b/cmake/data.cmake index 7c7927686e..eebf43ddc8 100644 --- a/cmake/data.cmake +++ b/cmake/data.cmake @@ -63,8 +63,11 @@ file(COPY "${PHONEME_SRC_DIR}" DESTINATION "${DATA_DIST_ROOT}") set(ESPEAK_RUN_ENV ${CMAKE_COMMAND} -E env "ESPEAK_DATA_PATH=${DATA_DIST_ROOT}") set(ESPEAK_RUN_CMD ${ESPEAK_RUN_ENV} $ENV{VALGRIND} "$") +set(espeak_ng_dll_path "$") + add_custom_command( OUTPUT "${DATA_DIST_DIR}/intonations" + COMMAND set "PATH=${espeak_ng_dll_path};%PATH%" COMMAND ${ESPEAK_RUN_CMD} --compile-intonations WORKING_DIRECTORY "${PHONEME_SRC_DIR}" COMMENT "Compile intonations" @@ -95,6 +98,7 @@ add_custom_command( "${DATA_DIST_DIR}/phondata-manifest" "${DATA_DIST_DIR}/phonindex" "${DATA_DIST_DIR}/phontab" + COMMAND set "PATH=${espeak_ng_dll_path};%PATH%" COMMAND ${ESPEAK_RUN_CMD} --compile-phonemes WORKING_DIRECTORY "${PHONEME_SRC_DIR}" COMMENT "Compile phonemes" @@ -131,6 +135,7 @@ foreach(_dict_name ${_dict_compile_list}) add_custom_command( OUTPUT "${_dict_target}" + COMMAND set "PATH=${espeak_ng_dll_path};%PATH%" COMMAND ${CMAKE_COMMAND} -E copy ${_dict_deps} "${DICT_TMP_DIR}/" COMMAND ${ESPEAK_RUN_CMD} --compile=${_dict_name} WORKING_DIRECTORY "${DICT_TMP_DIR}" From c97880fa9c1b1c2e0829514afefe72904b40fddb Mon Sep 17 00:00:00 2001 From: Fangjun Kuang Date: Mon, 27 Nov 2023 19:15:02 +0800 Subject: [PATCH 4/8] minor fixes --- cmake/data.cmake | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/cmake/data.cmake b/cmake/data.cmake index eebf43ddc8..f9465268c0 100644 --- a/cmake/data.cmake +++ b/cmake/data.cmake @@ -60,14 +60,11 @@ file(COPY "${DATA_SRC_DIR}/lang" DESTINATION "${DATA_DIST_DIR}") file(COPY "${DATA_SRC_DIR}/voices/!v" DESTINATION "${DATA_DIST_DIR}/voices") file(COPY "${PHONEME_SRC_DIR}" DESTINATION "${DATA_DIST_ROOT}") -set(ESPEAK_RUN_ENV ${CMAKE_COMMAND} -E env "ESPEAK_DATA_PATH=${DATA_DIST_ROOT}") +set(ESPEAK_RUN_ENV ${CMAKE_COMMAND} -E env "ESPEAK_DATA_PATH=${DATA_DIST_ROOT}" "PATH=$") set(ESPEAK_RUN_CMD ${ESPEAK_RUN_ENV} $ENV{VALGRIND} "$") -set(espeak_ng_dll_path "$") - add_custom_command( OUTPUT "${DATA_DIST_DIR}/intonations" - COMMAND set "PATH=${espeak_ng_dll_path};%PATH%" COMMAND ${ESPEAK_RUN_CMD} --compile-intonations WORKING_DIRECTORY "${PHONEME_SRC_DIR}" COMMENT "Compile intonations" @@ -98,7 +95,6 @@ add_custom_command( "${DATA_DIST_DIR}/phondata-manifest" "${DATA_DIST_DIR}/phonindex" "${DATA_DIST_DIR}/phontab" - COMMAND set "PATH=${espeak_ng_dll_path};%PATH%" COMMAND ${ESPEAK_RUN_CMD} --compile-phonemes WORKING_DIRECTORY "${PHONEME_SRC_DIR}" COMMENT "Compile phonemes" @@ -135,7 +131,6 @@ foreach(_dict_name ${_dict_compile_list}) add_custom_command( OUTPUT "${_dict_target}" - COMMAND set "PATH=${espeak_ng_dll_path};%PATH%" COMMAND ${CMAKE_COMMAND} -E copy ${_dict_deps} "${DICT_TMP_DIR}/" COMMAND ${ESPEAK_RUN_CMD} --compile=${_dict_name} WORKING_DIRECTORY "${DICT_TMP_DIR}" From c857195d8a9bc492314b607e346fea154a21a901 Mon Sep 17 00:00:00 2001 From: Fangjun Kuang Date: Mon, 27 Nov 2023 20:36:28 +0800 Subject: [PATCH 5/8] Fix building on Windows --- cmake/data.cmake | 2 +- src/CMakeLists.txt | 3 +- src/include/espeak/speak_lib.h | 716 +++++++++++++++++++++++++++++++- src/libespeak-ng/CMakeLists.txt | 13 +- 4 files changed, 718 insertions(+), 16 deletions(-) mode change 120000 => 100644 src/include/espeak/speak_lib.h diff --git a/cmake/data.cmake b/cmake/data.cmake index f9465268c0..7c7927686e 100644 --- a/cmake/data.cmake +++ b/cmake/data.cmake @@ -60,7 +60,7 @@ file(COPY "${DATA_SRC_DIR}/lang" DESTINATION "${DATA_DIST_DIR}") file(COPY "${DATA_SRC_DIR}/voices/!v" DESTINATION "${DATA_DIST_DIR}/voices") file(COPY "${PHONEME_SRC_DIR}" DESTINATION "${DATA_DIST_ROOT}") -set(ESPEAK_RUN_ENV ${CMAKE_COMMAND} -E env "ESPEAK_DATA_PATH=${DATA_DIST_ROOT}" "PATH=$") +set(ESPEAK_RUN_ENV ${CMAKE_COMMAND} -E env "ESPEAK_DATA_PATH=${DATA_DIST_ROOT}") set(ESPEAK_RUN_CMD ${ESPEAK_RUN_ENV} $ENV{VALGRIND} "$") add_custom_command( diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 03b4a7d9fa..48013384eb 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -6,7 +6,6 @@ add_subdirectory(speechPlayer) add_subdirectory(libespeak-ng) add_executable(espeak-ng-bin espeak-ng.c) -set_target_properties(espeak-ng-bin PROPERTIES OUTPUT_NAME espeak-ng) target_link_libraries( espeak-ng-bin PRIVATE espeak-ng espeak-ng-config ) @@ -33,4 +32,4 @@ if (ESPEAK_COMPAT AND NOT WIN32) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/speak-ng DESTINATION bin) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/espeak DESTINATION bin) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/speak DESTINATION bin) -endif() \ No newline at end of file +endif() diff --git a/src/include/espeak/speak_lib.h b/src/include/espeak/speak_lib.h deleted file mode 120000 index aef4ce539b..0000000000 --- a/src/include/espeak/speak_lib.h +++ /dev/null @@ -1 +0,0 @@ -../espeak-ng/speak_lib.h \ No newline at end of file diff --git a/src/include/espeak/speak_lib.h b/src/include/espeak/speak_lib.h new file mode 100644 index 0000000000..c15d140965 --- /dev/null +++ b/src/include/espeak/speak_lib.h @@ -0,0 +1,715 @@ +#ifndef SPEAK_LIB_H +#define SPEAK_LIB_H +/*************************************************************************** + * Copyright (C) 2005 to 2012 by Jonathan Duddington * + * email: jonsd@users.sourceforge.net * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, see: * + * . * + ***************************************************************************/ + + +/*************************************************************/ +/* This is the header file for the library version of espeak */ +/* */ +/*************************************************************/ + +#include +#include + +#if defined(_WIN32) || defined(_WIN64) +#ifdef LIBESPEAK_NG_EXPORT +#define ESPEAK_API __declspec(dllexport) +#else +#define ESPEAK_API __declspec(dllimport) +#endif +#else +#define ESPEAK_API +#endif + +#define ESPEAK_API_REVISION 12 +/* +Revision 2 + Added parameter "options" to eSpeakInitialize() + +Revision 3 + Added espeakWORDGAP to espeak_PARAMETER + +Revision 4 + Added flags parameter to espeak_CompileDictionary() + +Revision 5 + Added espeakCHARS_16BIT + +Revision 6 + Added macros: espeakRATE_MINIMUM, espeakRATE_MAXIMUM, espeakRATE_NORMAL + +Revision 7 24.Dec.2011 + Changed espeak_EVENT structure to add id.string[] for phoneme mnemonics. + Added espeakINITIALIZE_PHONEME_IPA option for espeak_Initialize() to report phonemes as IPA names. + +Revision 8 26.Apr.2013 + Added function espeak_TextToPhonemes(). + +Revision 9 30.May.2013 + Changed function espeak_TextToPhonemes(). + +Revision 10 29.Aug.2014 + Changed phonememode parameter to espeak_TextToPhonemes() and espeak_SetPhonemeTrace + +Revision 11 (espeak-ng) + Made ESPEAK_API import/export symbols correctly on Windows. + +Revision 12 (espeak-ng) + Exposed espeak_SetPhonemeCallback. This is available in eSpeak, but was not exposed in this header. + +*/ + /********************/ + /* Initialization */ + /********************/ + +// values for 'value' in espeak_SetParameter(espeakRATE, value, 0), nominally in words-per-minute +#define espeakRATE_MINIMUM 80 +#define espeakRATE_MAXIMUM 450 +#define espeakRATE_NORMAL 175 + + +typedef enum { + espeakEVENT_LIST_TERMINATED = 0, // Retrieval mode: terminates the event list. + espeakEVENT_WORD = 1, // Start of word + espeakEVENT_SENTENCE = 2, // Start of sentence + espeakEVENT_MARK = 3, // Mark + espeakEVENT_PLAY = 4, // Audio element + espeakEVENT_END = 5, // End of sentence or clause + espeakEVENT_MSG_TERMINATED = 6, // End of message + espeakEVENT_PHONEME = 7, // Phoneme, if enabled in espeak_Initialize() + espeakEVENT_SAMPLERATE = 8 // internal use, set sample rate +} espeak_EVENT_TYPE; + + + +typedef struct { + espeak_EVENT_TYPE type; + unsigned int unique_identifier; // message identifier (or 0 for key or character) + int text_position; // the number of characters from the start of the text + int length; // word length, in characters (for espeakEVENT_WORD) + int audio_position; // the time in mS within the generated speech output data + int sample; // sample id (internal use) + void* user_data; // pointer supplied by the calling program + union { + int number; // used for WORD and SENTENCE events. + const char *name; // used for MARK and PLAY events. UTF8 string + char string[8]; // used for phoneme names (UTF8). Terminated by a zero byte unless the name needs the full 8 bytes. + } id; +} espeak_EVENT; +/* + When a message is supplied to espeak_synth, the request is buffered and espeak_synth returns. When the message is really processed, the callback function will be repetedly called. + + + In RETRIEVAL mode, the callback function supplies to the calling program the audio data and an event list terminated by 0 (LIST_TERMINATED). + + In PLAYBACK mode, the callback function is called as soon as an event happens. + + For example suppose that the following message is supplied to espeak_Synth: + "hello, hello." + + + * Once processed in RETRIEVAL mode, it could lead to 3 calls of the callback function : + + ** Block 1: +