Support WebAssembly for text-to-speech (#577)
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
function(download_espeak_ng_for_piper)
|
||||
include(FetchContent)
|
||||
|
||||
set(espeak_ng_URL "https://github.com/csukuangfj/espeak-ng/archive/c58d2a4a88e9a291ca448f046e15c6188cbd3b3a.zip")
|
||||
set(espeak_ng_URL2 "")
|
||||
set(espeak_ng_HASH "SHA256=8a48251e6926133dd91fcf6cb210c7c2e290a9b578d269446e2d32d710b0dfa0")
|
||||
set(espeak_ng_URL "https://github.com/csukuangfj/espeak-ng/archive/69bf6927964fb042aeb827cfdf6082a30f5802eb.zip")
|
||||
set(espeak_ng_URL2 "https://hub.nuaa.cf/csukuangfj/espeak-ng/archive/69bf6927964fb042aeb827cfdf6082a30f5802eb.zip")
|
||||
set(espeak_ng_HASH "SHA256=745e35b21ece6804b4a1839722f9e625ac909380c8f85873ad71bf145877075a")
|
||||
|
||||
set(BUILD_ESPEAK_NG_TESTS OFF CACHE BOOL "" FORCE)
|
||||
set(USE_ASYNC OFF CACHE BOOL "" FORCE)
|
||||
@@ -15,14 +15,18 @@ function(download_espeak_ng_for_piper)
|
||||
set(EXTRA_cmn ON CACHE BOOL "" FORCE)
|
||||
set(EXTRA_ru ON CACHE BOOL "" FORCE)
|
||||
|
||||
if(SHERPA_ONNX_ENABLE_WASM)
|
||||
set(BUILD_ESPEAK_NG_EXE OFF CACHE BOOL "" FORCE)
|
||||
endif()
|
||||
|
||||
# If you don't have access to the Internet,
|
||||
# please pre-download kaldi-decoder
|
||||
set(possible_file_locations
|
||||
$ENV{HOME}/Downloads/espeak-ng-c58d2a4a88e9a291ca448f046e15c6188cbd3b3a.zip
|
||||
${CMAKE_SOURCE_DIR}/espeak-ng-c58d2a4a88e9a291ca448f046e15c6188cbd3b3a.zip
|
||||
${CMAKE_BINARY_DIR}/espeak-ng-c58d2a4a88e9a291ca448f046e15c6188cbd3b3a.zip
|
||||
/tmp/espeak-ng-c58d2a4a88e9a291ca448f046e15c6188cbd3b3a.zip
|
||||
/star-fj/fangjun/download/github/espeak-ng-c58d2a4a88e9a291ca448f046e15c6188cbd3b3a.zip
|
||||
$ENV{HOME}/Downloads/espeak-ng-69bf6927964fb042aeb827cfdf6082a30f5802eb.zip
|
||||
${CMAKE_SOURCE_DIR}/espeak-ng-69bf6927964fb042aeb827cfdf6082a30f5802eb.zip
|
||||
${CMAKE_BINARY_DIR}/espeak-ng-69bf6927964fb042aeb827cfdf6082a30f5802eb.zip
|
||||
/tmp/espeak-ng-69bf6927964fb042aeb827cfdf6082a30f5802eb.zip
|
||||
/star-fj/fangjun/download/github/espeak-ng-69bf6927964fb042aeb827cfdf6082a30f5802eb.zip
|
||||
)
|
||||
|
||||
foreach(f IN LISTS possible_file_locations)
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
function(download_kaldi_decoder)
|
||||
include(FetchContent)
|
||||
|
||||
set(kaldi_decoder_URL "https://github.com/k2-fsa/kaldi-decoder/archive/refs/tags/v0.2.3.tar.gz")
|
||||
set(kaldi_decoder_URL2 "https://huggingface.co/csukuangfj/sherpa-onnx-cmake-deps/resolve/main/kaldi-decoder-0.2.3.tar.gz")
|
||||
set(kaldi_decoder_HASH "SHA256=98bf445a5b7961ccf3c3522317d900054eaadb6a9cdcf4531e7d9caece94a56d")
|
||||
set(kaldi_decoder_URL "https://github.com/k2-fsa/kaldi-decoder/archive/refs/tags/v0.2.4.tar.gz")
|
||||
set(kaldi_decoder_URL2 "https://hub.nuaa.cf/k2-fsa/kaldi-decoder/archive/refs/tags/v0.2.4.tar.gz")
|
||||
set(kaldi_decoder_HASH "SHA256=136d96c2f1f8ec44de095205f81a6ce98981cd867fe4ba840f9415a0b58fe601")
|
||||
|
||||
set(KALDI_DECODER_BUILD_PYTHON OFF CACHE BOOL "" FORCE)
|
||||
set(KALDI_DECODER_ENABLE_TESTS OFF CACHE BOOL "" FORCE)
|
||||
@@ -12,11 +12,11 @@ function(download_kaldi_decoder)
|
||||
# If you don't have access to the Internet,
|
||||
# please pre-download kaldi-decoder
|
||||
set(possible_file_locations
|
||||
$ENV{HOME}/Downloads/kaldi-decoder-0.2.3.tar.gz
|
||||
${CMAKE_SOURCE_DIR}/kaldi-decoder-0.2.3.tar.gz
|
||||
${CMAKE_BINARY_DIR}/kaldi-decoder-0.2.3.tar.gz
|
||||
/tmp/kaldi-decoder-0.2.3.tar.gz
|
||||
/star-fj/fangjun/download/github/kaldi-decoder-0.2.3.tar.gz
|
||||
$ENV{HOME}/Downloads/kaldi-decoder-0.2.4.tar.gz
|
||||
${CMAKE_SOURCE_DIR}/kaldi-decoder-0.2.4.tar.gz
|
||||
${CMAKE_BINARY_DIR}/kaldi-decoder-0.2.4.tar.gz
|
||||
/tmp/kaldi-decoder-0.2.4.tar.gz
|
||||
/star-fj/fangjun/download/github/kaldi-decoder-0.2.4.tar.gz
|
||||
)
|
||||
|
||||
foreach(f IN LISTS possible_file_locations)
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
function(download_kaldifst)
|
||||
include(FetchContent)
|
||||
|
||||
set(kaldifst_URL "https://github.com/k2-fsa/kaldifst/archive/refs/tags/v1.7.9.tar.gz")
|
||||
set(kaldifst_URL2 "https://huggingface.co/csukuangfj/kaldi-hmm-gmm-cmake-deps/resolve/main/kaldifst-1.7.9.tar.gz")
|
||||
set(kaldifst_HASH "SHA256=8c653021491dca54c38ab659565edfab391418a79ae87099257863cd5664dd39")
|
||||
set(kaldifst_URL "https://github.com/k2-fsa/kaldifst/archive/refs/tags/v1.7.10.tar.gz")
|
||||
set(kaldifst_URL2 "https://hub.nuaa.cf/k2-fsa/kaldifst/archive/refs/tags/v1.7.10.tar.gz")
|
||||
set(kaldifst_HASH "SHA256=7f7b3173a6584a6b1987f65ae7af2ac453d66b845f875a9d31074b8d2cd0de54")
|
||||
|
||||
# If you don't have access to the Internet,
|
||||
# please pre-download kaldifst
|
||||
set(possible_file_locations
|
||||
$ENV{HOME}/Downloads/kaldifst-1.7.9.tar.gz
|
||||
${CMAKE_SOURCE_DIR}/kaldifst-1.7.9.tar.gz
|
||||
${CMAKE_BINARY_DIR}/kaldifst-1.7.9.tar.gz
|
||||
/tmp/kaldifst-1.7.9.tar.gz
|
||||
/star-fj/fangjun/download/github/kaldifst-1.7.9.tar.gz
|
||||
$ENV{HOME}/Downloads/kaldifst-1.7.10.tar.gz
|
||||
${CMAKE_SOURCE_DIR}/kaldifst-1.7.10.tar.gz
|
||||
${CMAKE_BINARY_DIR}/kaldifst-1.7.10.tar.gz
|
||||
/tmp/kaldifst-1.7.10.tar.gz
|
||||
/star-fj/fangjun/download/github/kaldifst-1.7.10.tar.gz
|
||||
)
|
||||
|
||||
foreach(f IN LISTS possible_file_locations)
|
||||
|
||||
60
cmake/onnxruntime-wasm-simd.cmake
Normal file
60
cmake/onnxruntime-wasm-simd.cmake
Normal file
@@ -0,0 +1,60 @@
|
||||
# Copyright (c) 2022-2024 Xiaomi Corporation
|
||||
message(STATUS "CMAKE_SYSTEM_NAME: ${CMAKE_SYSTEM_NAME}")
|
||||
message(STATUS "CMAKE_SYSTEM_PROCESSOR: ${CMAKE_SYSTEM_PROCESSOR}")
|
||||
|
||||
if(NOT SHERPA_ONNX_ENABLE_WASM)
|
||||
message(FATAL_ERROR "This file is for WebAssembly.")
|
||||
endif()
|
||||
|
||||
if(BUILD_SHARED_LIBS)
|
||||
message(FATAL_ERROR "BUILD_SHARED_LIBS should be OFF for WebAssembly")
|
||||
endif()
|
||||
|
||||
set(onnxruntime_URL "https://github.com/csukuangfj/onnxruntime-libs/releases/download/v1.17.0/onnxruntime-wasm-static_lib-simd-1.17.0.zip")
|
||||
set(onnxruntime_URL2 "https://hub.nuaa.cf/csukuangfj/onnxruntime-libs/releases/download/v1.17.0/onnxruntime-wasm-static_lib-simd-1.17.0.zip")
|
||||
set(onnxruntime_HASH "SHA256=0ee6120d2ade093eff731af792fd137ac2db580eb2dc5b8bf39e0897b0d7afd9")
|
||||
|
||||
# If you don't have access to the Internet,
|
||||
# please download onnxruntime to one of the following locations.
|
||||
# You can add more if you want.
|
||||
set(possible_file_locations
|
||||
$ENV{HOME}/Downloads/onnxruntime-wasm-static_lib-simd-1.17.0.zip
|
||||
${CMAKE_SOURCE_DIR}/onnxruntime-wasm-static_lib-simd-1.17.0.zip
|
||||
${CMAKE_BINARY_DIR}/onnxruntime-wasm-static_lib-simd-1.17.0.zip
|
||||
/tmp/onnxruntime-wasm-static_lib-simd-1.17.0.zip
|
||||
/star-fj/fangjun/download/github/onnxruntime-wasm-static_lib-simd-1.17.0.zip
|
||||
)
|
||||
|
||||
foreach(f IN LISTS possible_file_locations)
|
||||
if(EXISTS ${f})
|
||||
set(onnxruntime_URL "${f}")
|
||||
file(TO_CMAKE_PATH "${onnxruntime_URL}" onnxruntime_URL)
|
||||
message(STATUS "Found local downloaded onnxruntime: ${onnxruntime_URL}")
|
||||
set(onnxruntime_URL2)
|
||||
break()
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
FetchContent_Declare(onnxruntime
|
||||
URL
|
||||
${onnxruntime_URL}
|
||||
${onnxruntime_URL2}
|
||||
URL_HASH ${onnxruntime_HASH}
|
||||
)
|
||||
|
||||
FetchContent_GetProperties(onnxruntime)
|
||||
if(NOT onnxruntime_POPULATED)
|
||||
message(STATUS "Downloading onnxruntime from ${onnxruntime_URL}")
|
||||
FetchContent_Populate(onnxruntime)
|
||||
endif()
|
||||
message(STATUS "onnxruntime is downloaded to ${onnxruntime_SOURCE_DIR}")
|
||||
|
||||
# for static libraries, we use onnxruntime_lib_files directly below
|
||||
include_directories(${onnxruntime_SOURCE_DIR}/include)
|
||||
|
||||
file(GLOB onnxruntime_lib_files "${onnxruntime_SOURCE_DIR}/lib/lib*.a")
|
||||
|
||||
set(onnxruntime_lib_files ${onnxruntime_lib_files} PARENT_SCOPE)
|
||||
|
||||
message(STATUS "onnxruntime lib files: ${onnxruntime_lib_files}")
|
||||
install(FILES ${onnxruntime_lib_files} DESTINATION lib)
|
||||
@@ -4,8 +4,9 @@ function(download_onnxruntime)
|
||||
|
||||
message(STATUS "CMAKE_SYSTEM_NAME: ${CMAKE_SYSTEM_NAME}")
|
||||
message(STATUS "CMAKE_SYSTEM_PROCESSOR: ${CMAKE_SYSTEM_PROCESSOR}")
|
||||
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL Linux AND CMAKE_SYSTEM_PROCESSOR STREQUAL aarch64)
|
||||
if(SHERPA_ONNX_ENABLE_WASM)
|
||||
include(onnxruntime-wasm-simd)
|
||||
elseif(CMAKE_SYSTEM_NAME STREQUAL Linux AND CMAKE_SYSTEM_PROCESSOR STREQUAL aarch64)
|
||||
if(BUILD_SHARED_LIBS)
|
||||
include(onnxruntime-linux-aarch64)
|
||||
else()
|
||||
|
||||
Reference in New Issue
Block a user