|
| 1 | +function(download_espeak_ng_for_piper) |
| 2 | + include(FetchContent) |
| 3 | + |
| 4 | + set(espeak_ng_URL "https://github.com/csukuangfj/espeak-ng/archive/c58d2a4a88e9a291ca448f046e15c6188cbd3b3a.zip") |
| 5 | + set(espeak_ng_URL2 "") |
| 6 | + set(espeak_ng_HASH "SHA256=8a48251e6926133dd91fcf6cb210c7c2e290a9b578d269446e2d32d710b0dfa0") |
| 7 | + |
| 8 | + set(USE_ASYNC OFF CACHE BOOL "" FORCE) |
| 9 | + set(USE_MBROLA OFF CACHE BOOL "" FORCE) |
| 10 | + set(USE_LIBSONIC OFF CACHE BOOL "" FORCE) |
| 11 | + set(USE_LIBPCAUDIO OFF CACHE BOOL "" FORCE) |
| 12 | + set(USE_KLATT OFF CACHE BOOL "" FORCE) |
| 13 | + set(USE_SPEECHPLAYER OFF CACHE BOOL "" FORCE) |
| 14 | + set(EXTRA_cmn ON CACHE BOOL "" FORCE) |
| 15 | + set(EXTRA_ru ON CACHE BOOL "" FORCE) |
| 16 | + |
| 17 | + # If you don't have access to the Internet, |
| 18 | + # please pre-download kaldi-decoder |
| 19 | + set(possible_file_locations |
| 20 | + $ENV{HOME}/Downloads/espeak-ng-c58d2a4a88e9a291ca448f046e15c6188cbd3b3a.zip |
| 21 | + ${PROJECT_SOURCE_DIR}/espeak-ng-c58d2a4a88e9a291ca448f046e15c6188cbd3b3a.zip |
| 22 | + ${PROJECT_BINARY_DIR}/espeak-ng-c58d2a4a88e9a291ca448f046e15c6188cbd3b3a.zip |
| 23 | + /tmp/espeak-ng-c58d2a4a88e9a291ca448f046e15c6188cbd3b3a.zip |
| 24 | + /star-fj/fangjun/download/github/espeak-ng-c58d2a4a88e9a291ca448f046e15c6188cbd3b3a.zip |
| 25 | + ) |
| 26 | + |
| 27 | + foreach(f IN LISTS possible_file_locations) |
| 28 | + if(EXISTS ${f}) |
| 29 | + set(espeak_ng_URL "${f}") |
| 30 | + file(TO_CMAKE_PATH "${espeak_ng_URL}" espeak_ng_URL) |
| 31 | + message(STATUS "Found local downloaded espeak-ng: ${espeak_ng_URL}") |
| 32 | + set(espeak_ng_URL2 ) |
| 33 | + break() |
| 34 | + endif() |
| 35 | + endforeach() |
| 36 | + |
| 37 | + FetchContent_Declare(espeak_ng |
| 38 | + URL |
| 39 | + ${espeak_ng_URL} |
| 40 | + ${espeak_ng_URL2} |
| 41 | + URL_HASH ${espeak_ng_HASH} |
| 42 | + ) |
| 43 | + |
| 44 | + FetchContent_GetProperties(espeak_ng) |
| 45 | + if(NOT espeak_ng_POPULATED) |
| 46 | + message(STATUS "Downloading espeak-ng from ${espeak_ng_URL}") |
| 47 | + FetchContent_Populate(espeak_ng) |
| 48 | + endif() |
| 49 | + message(STATUS "espeak-ng is downloaded to ${espeak_ng_SOURCE_DIR}") |
| 50 | + message(STATUS "espeak-ng binary dir is ${espeak_ng_BINARY_DIR}") |
| 51 | + |
| 52 | + add_subdirectory(${espeak_ng_SOURCE_DIR} ${espeak_ng_BINARY_DIR}) |
| 53 | + set(espeak_ng_SOURCE_DIR ${espeak_ng_SOURCE_DIR} PARENT_SCOPE) |
| 54 | + |
| 55 | + if(WIN32 AND MSVC) |
| 56 | + target_compile_options(ucd PUBLIC |
| 57 | + /wd4309 |
| 58 | + ) |
| 59 | + |
| 60 | + target_compile_options(espeak-ng PUBLIC |
| 61 | + /wd4005 |
| 62 | + /wd4018 |
| 63 | + /wd4067 |
| 64 | + /wd4068 |
| 65 | + /wd4090 |
| 66 | + /wd4101 |
| 67 | + /wd4244 |
| 68 | + /wd4267 |
| 69 | + /wd4996 |
| 70 | + ) |
| 71 | + |
| 72 | + if(TARGET espeak-ng-bin) |
| 73 | + target_compile_options(espeak-ng-bin PRIVATE |
| 74 | + /wd4244 |
| 75 | + /wd4024 |
| 76 | + /wd4047 |
| 77 | + /wd4067 |
| 78 | + /wd4267 |
| 79 | + /wd4996 |
| 80 | + ) |
| 81 | + endif() |
| 82 | + endif() |
| 83 | + |
| 84 | + if(UNIX AND NOT APPLE) |
| 85 | + target_compile_options(espeak-ng PRIVATE |
| 86 | + -Wno-unused-result |
| 87 | + -Wno-format-overflow |
| 88 | + -Wno-format-truncation |
| 89 | + -Wno-maybe-uninitialized |
| 90 | + -Wno-format |
| 91 | + ) |
| 92 | + |
| 93 | + if(TARGET espeak-ng-bin) |
| 94 | + target_compile_options(espeak-ng-bin PRIVATE |
| 95 | + -Wno-unused-result |
| 96 | + ) |
| 97 | + endif() |
| 98 | + endif() |
| 99 | + |
| 100 | + target_include_directories(espeak-ng |
| 101 | + INTERFACE |
| 102 | + ${espeak_ng_SOURCE_DIR}/src/include |
| 103 | + ${espeak_ng_SOURCE_DIR}/src/ucd-tools/src/include |
| 104 | + ) |
| 105 | + |
| 106 | + if(SHERPA_ONNX_ENABLE_PYTHON AND WIN32) |
| 107 | + install(TARGETS |
| 108 | + espeak-ng |
| 109 | + DESTINATION ..) |
| 110 | + else() |
| 111 | + install(TARGETS |
| 112 | + espeak-ng |
| 113 | + DESTINATION lib) |
| 114 | + endif() |
| 115 | + |
| 116 | + if(NOT BUILD_SHARED_LIBS) |
| 117 | + install(TARGETS ucd DESTINATION lib) |
| 118 | + endif() |
| 119 | + |
| 120 | + if(WIN32 AND BUILD_SHARED_LIBS) |
| 121 | + install(TARGETS |
| 122 | + espeak-ng |
| 123 | + DESTINATION bin) |
| 124 | + endif() |
| 125 | +endfunction() |
| 126 | + |
| 127 | +download_espeak_ng_for_piper() |
0 commit comments