diff --git a/cmake/asio.cmake b/cmake/asio.cmake index eaa262acb..9e3ce8d23 100644 --- a/cmake/asio.cmake +++ b/cmake/asio.cmake @@ -2,7 +2,7 @@ function(download_asio) include(FetchContent) set(asio_URL "https://github.com/chriskohlhoff/asio/archive/refs/tags/asio-1-24-0.tar.gz") - set(asio_URL2 "https://hub.nuaa.cf/chriskohlhoff/asio/archive/refs/tags/asio-1-24-0.tar.gz") + set(asio_URL2 "https://hf-mirror.com/csukuangfj/sherpa-onnx-cmake-deps/resolve/main/asio-asio-1-24-0.tar.gz") set(asio_HASH "SHA256=cbcaaba0f66722787b1a7c33afe1befb3a012b5af3ad7da7ff0f6b8c9b7a8a5b") # If you don't have access to the Internet, diff --git a/cmake/cargs.cmake b/cmake/cargs.cmake index 54487a6f0..d7c605508 100644 --- a/cmake/cargs.cmake +++ b/cmake/cargs.cmake @@ -2,7 +2,7 @@ function(download_cargs) include(FetchContent) set(cargs_URL "https://github.com/likle/cargs/archive/refs/tags/v1.0.3.tar.gz") - set(cargs_URL2 "https://hub.nuaa.cf/likle/cargs/archive/refs/tags/v1.0.3.tar.gz") + set(cargs_URL2 "https://hf-mirror.com/csukuangfj/sherpa-onnx-cmake-deps/resolve/main/cargs-1.0.3.tar.gz") set(cargs_HASH "SHA256=ddba25bd35e9c6c75bc706c126001b8ce8e084d40ef37050e6aa6963e836eb8b") # If you don't have access to the Internet, diff --git a/cmake/cppjieba.cmake b/cmake/cppjieba.cmake index 9ad27d7b5..167da338f 100644 --- a/cmake/cppjieba.cmake +++ b/cmake/cppjieba.cmake @@ -2,7 +2,7 @@ function(download_cppjieba) include(FetchContent) set(cppjieba_URL "https://github.com/csukuangfj/cppjieba/archive/refs/tags/sherpa-onnx-2024-04-19.tar.gz") - set(cppjieba_URL2 "https://hub.nuaa.cf/csukuangfj/cppjieba/archive/refs/tags/sherpa-onnx-2024-04-19.tar.gz") + set(cppjieba_URL2 "https://hf-mirror.com/csukuangfj/sherpa-onnx-cmake-deps/resolve/main/cppjieba-sherpa-onnx-2024-04-19.tar.gz") set(cppjieba_HASH "SHA256=03e5264687f0efaef05487a07d49c3f4c0f743347bfbf825df4b30cc75ac5288") # If you don't have access to the Internet, diff --git a/cmake/eigen.cmake b/cmake/eigen.cmake index 154cdd4c2..9aef9abc8 100644 --- a/cmake/eigen.cmake +++ b/cmake/eigen.cmake @@ -2,7 +2,7 @@ function(download_eigen) include(FetchContent) set(eigen_URL "https://gitlab.com/libeigen/eigen/-/archive/3.4.0/eigen-3.4.0.tar.gz") - set(eigen_URL2 "https://huggingface.co/csukuangfj/kaldi-hmm-gmm-cmake-deps/resolve/main/eigen-3.4.0.tar.gz") + set(eigen_URL2 "https://hf-mirror.com/csukuangfj/sherpa-onnx-cmake-deps/resolve/main/eigen-3.4.0.tar.gz") set(eigen_HASH "SHA256=8586084f71f9bde545ee7fa6d00288b264a2b7ac3607b974e54d13e7162c1c72") # If you don't have access to the Internet, diff --git a/cmake/espeak-ng-for-piper.cmake b/cmake/espeak-ng-for-piper.cmake index b54a0a6bd..0ef825306 100644 --- a/cmake/espeak-ng-for-piper.cmake +++ b/cmake/espeak-ng-for-piper.cmake @@ -2,7 +2,7 @@ function(download_espeak_ng_for_piper) include(FetchContent) set(espeak_ng_URL "https://github.com/csukuangfj/espeak-ng/archive/f6fed6c58b5e0998b8e68c6610125e2d07d595a7.zip") - set(espeak_ng_URL2 "https://hub.nuaa.cf/csukuangfj/espeak-ng/archive/f6fed6c58b5e0998b8e68c6610125e2d07d595a7.zip") + set(espeak_ng_URL2 "https://hf-mirror.com/csukuangfj/sherpa-onnx-cmake-deps/resolve/main/espeak-ng-f6fed6c58b5e0998b8e68c6610125e2d07d595a7.zip") set(espeak_ng_HASH "SHA256=70cbf4050e7a014aae19140b05e57249da4720f56128459fbe3a93beaf971ae6") set(BUILD_ESPEAK_NG_TESTS OFF CACHE BOOL "" FORCE) diff --git a/cmake/googletest.cmake b/cmake/googletest.cmake index cf5fa10cc..a9bfd443b 100644 --- a/cmake/googletest.cmake +++ b/cmake/googletest.cmake @@ -2,7 +2,7 @@ function(download_googltest) include(FetchContent) set(googletest_URL "https://github.com/google/googletest/archive/refs/tags/v1.13.0.tar.gz") - set(googletest_URL2 "https://hub.nuaa.cf/google/googletest/archive/refs/tags/v1.13.0.tar.gz") + set(googletest_URL2 "https://hf-mirror.com/csukuangfj/sherpa-onnx-cmake-deps/resolve/main/googletest-1.13.0.tar.gz") set(googletest_HASH "SHA256=ad7fdba11ea011c1d925b3289cf4af2c66a352e18d4c7264392fead75e919363") # If you don't have access to the Internet, diff --git a/cmake/hclust-cpp.cmake b/cmake/hclust-cpp.cmake index 904081525..c84ccafc8 100644 --- a/cmake/hclust-cpp.cmake +++ b/cmake/hclust-cpp.cmake @@ -3,6 +3,7 @@ function(download_hclust_cpp) # The latest commit as of 2024.09.29 set(hclust_cpp_URL "https://github.com/csukuangfj/hclust-cpp/archive/refs/tags/2024-09-29.tar.gz") + set(hclust_cpp_URL2 "https://hf-mirror.com/csukuangfj/sherpa-onnx-cmake-deps/resolve/main/hclust-cpp-2024-09-29.tar.gz") set(hclust_cpp_HASH "SHA256=abab51448a3cb54272aae07522970306e0b2cc6479d59d7b19e7aee4d6cedd33") # If you don't have access to the Internet, @@ -20,6 +21,7 @@ function(download_hclust_cpp) set(hclust_cpp_URL "${f}") file(TO_CMAKE_PATH "${hclust_cpp_URL}" hclust_cpp_URL) message(STATUS "Found local downloaded hclust_cpp: ${hclust_cpp_URL}") + set(hclust_cpp_URL2) break() endif() endforeach() diff --git a/cmake/kaldi-decoder.cmake b/cmake/kaldi-decoder.cmake index d3d7ec2d5..91202342a 100644 --- a/cmake/kaldi-decoder.cmake +++ b/cmake/kaldi-decoder.cmake @@ -2,7 +2,7 @@ function(download_kaldi_decoder) include(FetchContent) set(kaldi_decoder_URL "https://github.com/k2-fsa/kaldi-decoder/archive/refs/tags/v0.2.6.tar.gz") - set(kaldi_decoder_URL2 "https://hub.nuaa.cf/k2-fsa/kaldi-decoder/archive/refs/tags/v0.2.6.tar.gz") + set(kaldi_decoder_URL2 "https://hf-mirror.com/csukuangfj/sherpa-onnx-cmake-deps/resolve/main/kaldi-decoder-0.2.6.tar.gz") set(kaldi_decoder_HASH "SHA256=b13c78b37495cafc6ef3f8a7b661b349c55a51abbd7f7f42f389408dcf86a463") set(KALDI_DECODER_BUILD_PYTHON OFF CACHE BOOL "" FORCE) diff --git a/cmake/kaldi-native-fbank.cmake b/cmake/kaldi-native-fbank.cmake index 2d87b6a8b..8f6803c88 100644 --- a/cmake/kaldi-native-fbank.cmake +++ b/cmake/kaldi-native-fbank.cmake @@ -2,7 +2,7 @@ function(download_kaldi_native_fbank) include(FetchContent) set(kaldi_native_fbank_URL "https://github.com/csukuangfj/kaldi-native-fbank/archive/refs/tags/v1.20.0.tar.gz") - set(kaldi_native_fbank_URL2 "https://hub.nuaa.cf/csukuangfj/kaldi-native-fbank/archive/refs/tags/v1.20.0.tar.gz") + set(kaldi_native_fbank_URL2 "https://hf-mirror.com/csukuangfj/sherpa-onnx-cmake-deps/resolve/main/kaldi-native-fbank-1.20.0.tar.gz") set(kaldi_native_fbank_HASH "SHA256=c6195b3cf374eef824644061d3c04f6b2a9267ae554169cbaa9865c89c1fe4f9") set(KALDI_NATIVE_FBANK_BUILD_TESTS OFF CACHE BOOL "" FORCE) diff --git a/cmake/kaldifst.cmake b/cmake/kaldifst.cmake index 765e2571a..034d8c444 100644 --- a/cmake/kaldifst.cmake +++ b/cmake/kaldifst.cmake @@ -2,7 +2,7 @@ function(download_kaldifst) include(FetchContent) set(kaldifst_URL "https://github.com/k2-fsa/kaldifst/archive/refs/tags/v1.7.11.tar.gz") - set(kaldifst_URL2 "https://hub.nuaa.cf/k2-fsa/kaldifst/archive/refs/tags/v1.7.11.tar.gz") + set(kaldifst_URL2 "https://hf-mirror.com/csukuangfj/sherpa-onnx-cmake-deps/resolve/main/kaldifst-1.7.11.tar.gz") set(kaldifst_HASH "SHA256=b43b3332faa2961edc730e47995a58cd4e22ead21905d55b0c4a41375b4a525f") # If you don't have access to the Internet, diff --git a/cmake/onnxruntime-linux-aarch64-static.cmake b/cmake/onnxruntime-linux-aarch64-static.cmake index 9606c79db..4752e0102 100644 --- a/cmake/onnxruntime-linux-aarch64-static.cmake +++ b/cmake/onnxruntime-linux-aarch64-static.cmake @@ -15,7 +15,7 @@ if(BUILD_SHARED_LIBS) endif() set(onnxruntime_URL "https://github.com/csukuangfj/onnxruntime-libs/releases/download/v1.17.1/onnxruntime-linux-aarch64-static_lib-1.17.1.zip") -set(onnxruntime_URL2 "https://hub.nuaa.cf/csukuangfj/onnxruntime-libs/releases/download/v1.17.1/onnxruntime-linux-aarch64-static_lib-1.17.1.zip") +set(onnxruntime_URL2 "https://hf-mirror.com/csukuangfj/onnxruntime-libs/resolve/main/onnxruntime-linux-aarch64-static_lib-1.17.1.zip") set(onnxruntime_HASH "SHA256=831b9a3869501040b4399de85f34c4f170e2bcbd41881edaeb553f8dc4080985") # If you don't have access to the Internet, diff --git a/cmake/onnxruntime-linux-aarch64.cmake b/cmake/onnxruntime-linux-aarch64.cmake index 096318e0b..a18f59e51 100644 --- a/cmake/onnxruntime-linux-aarch64.cmake +++ b/cmake/onnxruntime-linux-aarch64.cmake @@ -15,7 +15,7 @@ if(NOT BUILD_SHARED_LIBS) endif() set(onnxruntime_URL "https://github.com/csukuangfj/onnxruntime-libs/releases/download/v1.17.1/onnxruntime-linux-aarch64-glibc2_17-Release-1.17.1-patched.zip") -set(onnxruntime_URL2 "https://hub.nuaa.cf/csukuangfj/onnxruntime-libs/releases/download/v1.17.1/onnxruntime-linux-aarch64-glibc2_17-Release-1.17.1-patched.zip") +set(onnxruntime_URL2 "https://hf-mirror.com/csukuangfj/onnxruntime-libs/resolve/main/onnxruntime-linux-aarch64-glibc2_17-Release-1.17.1-patched.zip") set(onnxruntime_HASH "SHA256=6e0e68985f8dd1f643e5a4dbe7cd54c9e176a0cc62249c6bee0699b87fc6d4fb") # If you don't have access to the Internet, diff --git a/cmake/onnxruntime-linux-arm-static.cmake b/cmake/onnxruntime-linux-arm-static.cmake index cf2269afb..fa9170e34 100644 --- a/cmake/onnxruntime-linux-arm-static.cmake +++ b/cmake/onnxruntime-linux-arm-static.cmake @@ -15,7 +15,7 @@ if(BUILD_SHARED_LIBS) endif() set(onnxruntime_URL "https://github.com/csukuangfj/onnxruntime-libs/releases/download/v1.17.1/onnxruntime-linux-arm-static_lib-1.17.1.zip") -set(onnxruntime_URL2 "https://hub.nuaa.cf/csukuangfj/onnxruntime-libs/releases/download/v1.17.1/onnxruntime-linux-arm-static_lib-1.17.1.zip") +set(onnxruntime_URL2 "https://hf-mirror.com/csukuangfj/onnxruntime-libs/resolve/main/onnxruntime-linux-arm-static_lib-1.17.1.zip") set(onnxruntime_HASH "SHA256=3f2ba38156d2facfb732c0fe53bc1eaaf2791d9a91dd240380e3d53716798b09") # If you don't have access to the Internet, diff --git a/cmake/onnxruntime-linux-arm.cmake b/cmake/onnxruntime-linux-arm.cmake index a3adfaebd..28bd42686 100644 --- a/cmake/onnxruntime-linux-arm.cmake +++ b/cmake/onnxruntime-linux-arm.cmake @@ -15,7 +15,7 @@ if(NOT BUILD_SHARED_LIBS) endif() set(onnxruntime_URL "https://github.com/csukuangfj/onnxruntime-libs/releases/download/v1.17.1/onnxruntime-linux-arm-1.17.1-patched.zip") -set(onnxruntime_URL2 "https://hub.nuaa.cf/csukuangfj/onnxruntime-libs/releases/download/v1.17.1/onnxruntime-linux-arm-1.17.1-patched.zip") +set(onnxruntime_URL2 "https://hf-mirror.com/csukuangfj/onnxruntime-libs/resolve/main/onnxruntime-linux-arm-1.17.1-patched.zip") set(onnxruntime_HASH "SHA256=4ec00f7adc7341c068babea3d0f607349655e598222d4212115ae4f52619efdb") # If you don't have access to the Internet, diff --git a/cmake/onnxruntime-linux-riscv64-static.cmake b/cmake/onnxruntime-linux-riscv64-static.cmake index b400c4741..dec7cf1bb 100644 --- a/cmake/onnxruntime-linux-riscv64-static.cmake +++ b/cmake/onnxruntime-linux-riscv64-static.cmake @@ -15,7 +15,7 @@ if(BUILD_SHARED_LIBS) endif() set(onnxruntime_URL "https://github.com/csukuangfj/onnxruntime-libs/releases/download/v1.18.0/onnxruntime-linux-riscv64-static_lib-1.18.0.zip") -set(onnxruntime_URL2 "https://hub.nuaa.cf/csukuangfj/onnxruntime-libs/releases/download/v1.18.0/onnxruntime-linux-riscv64-static_lib-1.18.0.zip") +set(onnxruntime_URL2 "https://hf-mirror.com/csukuangfj/onnxruntime-libs/resolve/main/onnxruntime-linux-riscv64-static_lib-1.18.0.zip") set(onnxruntime_HASH "SHA256=77ecc51d8caf0953755db6edcdec2fc03bce3f6d379bedd635be50bb95f88da5") # If you don't have access to the Internet, diff --git a/cmake/onnxruntime-linux-riscv64.cmake b/cmake/onnxruntime-linux-riscv64.cmake index c773e5ecb..121459326 100644 --- a/cmake/onnxruntime-linux-riscv64.cmake +++ b/cmake/onnxruntime-linux-riscv64.cmake @@ -15,7 +15,7 @@ if(NOT BUILD_SHARED_LIBS) endif() set(onnxruntime_URL "https://github.com/csukuangfj/onnxruntime-libs/releases/download/v1.14.1/onnxruntime-linux-riscv64-glibc2_17-Release-1.14.1.zip") -set(onnxruntime_URL2 "https://hub.nuaa.cf/csukuangfj/onnxruntime-libs/releases/download/v1.14.1/onnxruntime-linux-riscv64-glibc2_17-Release-1.14.1.zip") +set(onnxruntime_URL2 "https://hf-mirror.com/csukuangfj/onnxruntime-libs/resolve/main/onnxruntime-linux-riscv64-glibc2_17-Release-1.14.1.zip") set(onnxruntime_HASH "SHA256=c2cbc5af081ff82f46640befd85433811486daaf28e702163c6e4e75020fde81") # If you don't have access to the Internet, diff --git a/cmake/onnxruntime-linux-x86_64-gpu.cmake b/cmake/onnxruntime-linux-x86_64-gpu.cmake index 5407a0b82..7aed2526f 100644 --- a/cmake/onnxruntime-linux-x86_64-gpu.cmake +++ b/cmake/onnxruntime-linux-x86_64-gpu.cmake @@ -20,7 +20,7 @@ endif() set(onnxruntime_URL "https://github.com/csukuangfj/onnxruntime-libs/releases/download/v1.17.1/onnxruntime-linux-x64-gpu-1.17.1-patched.zip") -set(onnxruntime_URL2 "https://hub.nuaa.cf/csukuangfj/onnxruntime-libs/releases/download/v1.17.1/onnxruntime-linux-x64-gpu-1.17.1-patched.zip") +set(onnxruntime_URL2 "https://hf-mirror.com/csukuangfj/onnxruntime-libs/resolve/main/onnxruntime-linux-x64-gpu-1.17.1-patched.zip") set(onnxruntime_HASH "SHA256=1261de176e8d9d4d2019f8fa8c732c6d11494f3c6e73168ab6d2cc0903f22551") # If you don't have access to the Internet, diff --git a/cmake/onnxruntime-linux-x86_64-static.cmake b/cmake/onnxruntime-linux-x86_64-static.cmake index c6bb867b2..f72f9ad5e 100644 --- a/cmake/onnxruntime-linux-x86_64-static.cmake +++ b/cmake/onnxruntime-linux-x86_64-static.cmake @@ -15,7 +15,7 @@ if(BUILD_SHARED_LIBS) endif() set(onnxruntime_URL "https://github.com/csukuangfj/onnxruntime-libs/releases/download/v1.17.1/onnxruntime-linux-x64-static_lib-1.17.1-glibc2_17.zip") -set(onnxruntime_URL2 "https://hub.nuaa.cf/csukuangfj/onnxruntime-libs/releases/download/v1.17.1/onnxruntime-linux-x64-static_lib-1.17.1-glibc2_17.zip") +set(onnxruntime_URL2 "https://hf-mirror.com/csukuangfj/onnxruntime-libs/resolve/main/onnxruntime-linux-x64-static_lib-1.17.1-glibc2_17.zip") set(onnxruntime_HASH "SHA256=b646beeb983de843a267096d4457d832f93089f5e7264fd54b48cff207cb2068") # If you don't have access to the Internet, diff --git a/cmake/onnxruntime-linux-x86_64.cmake b/cmake/onnxruntime-linux-x86_64.cmake index eaa6f7608..361f4d0d8 100644 --- a/cmake/onnxruntime-linux-x86_64.cmake +++ b/cmake/onnxruntime-linux-x86_64.cmake @@ -15,7 +15,7 @@ if(NOT BUILD_SHARED_LIBS) endif() set(onnxruntime_URL "https://github.com/csukuangfj/onnxruntime-libs/releases/download/v1.17.1/onnxruntime-linux-x64-glibc2_17-Release-1.17.1-patched.zip") -set(onnxruntime_URL2 "https://hub.nuaa.cf/csukuangfj/onnxruntime-libs/releases/download/v1.17.1/onnxruntime-linux-x64-glibc2_17-Release-1.17.1-patched.zip") +set(onnxruntime_URL2 "https://hf-mirror.com/csukuangfj/onnxruntime-libs/resolve/main/onnxruntime-linux-x64-glibc2_17-Release-1.17.1-patched.zip") set(onnxruntime_HASH "SHA256=cb90c51a195bdd453aaf1582f3ef63b466dafbb15c4b8a552ca4dce3769e1d1e") # If you don't have access to the Internet, diff --git a/cmake/onnxruntime-osx-arm64-static.cmake b/cmake/onnxruntime-osx-arm64-static.cmake index 494e263ff..7cd5a63ba 100644 --- a/cmake/onnxruntime-osx-arm64-static.cmake +++ b/cmake/onnxruntime-osx-arm64-static.cmake @@ -13,7 +13,7 @@ if(BUILD_SHARED_LIBS) endif() set(onnxruntime_URL "https://github.com/csukuangfj/onnxruntime-libs/releases/download/v1.17.1/onnxruntime-osx-arm64-static_lib-1.17.1.zip") -set(onnxruntime_URL2 "https://hub.nuaa.cf/csukuangfj/onnxruntime-libs/releases/download/v1.17.1/onnxruntime-osx-arm64-static_lib-1.17.1.zip") +set(onnxruntime_URL2 "https://hf-mirror.com/csukuangfj/onnxruntime-libs/resolve/main/onnxruntime-osx-arm64-static_lib-1.17.1.zip") set(onnxruntime_HASH "SHA256=b88a4017251c159fea005aefe836bd0cf4d0bc7454e2810784f84a42143f17eb") # If you don't have access to the Internet, diff --git a/cmake/onnxruntime-osx-arm64.cmake b/cmake/onnxruntime-osx-arm64.cmake index 3998cc8b4..e3c986a44 100644 --- a/cmake/onnxruntime-osx-arm64.cmake +++ b/cmake/onnxruntime-osx-arm64.cmake @@ -13,7 +13,7 @@ if(NOT BUILD_SHARED_LIBS) endif() set(onnxruntime_URL "https://github.com/microsoft/onnxruntime/releases/download/v1.17.1/onnxruntime-osx-arm64-1.17.1.tgz") -set(onnxruntime_URL2 "https://hub.nuaa.cf/microsoft/onnxruntime/releases/download/v1.17.1/onnxruntime-osx-arm64-1.17.1.tgz") +set(onnxruntime_URL2 "https://hf-mirror.com/csukuangfj/onnxruntime-libs/resolve/main/onnxruntime-osx-arm64-1.17.1.tgz") set(onnxruntime_HASH "SHA256=89566f424624a7ad9a7d9d5e413c44b9639a994d7171cf409901d125b16e2bb3") # If you don't have access to the Internet, diff --git a/cmake/onnxruntime-osx-universal-static.cmake b/cmake/onnxruntime-osx-universal-static.cmake index 2abcf46b4..5bf635b8e 100644 --- a/cmake/onnxruntime-osx-universal-static.cmake +++ b/cmake/onnxruntime-osx-universal-static.cmake @@ -14,7 +14,7 @@ if(BUILD_SHARED_LIBS) endif() set(onnxruntime_URL "https://github.com/csukuangfj/onnxruntime-libs/releases/download/v1.17.1/onnxruntime-osx-universal2-static_lib-1.17.1.zip") -set(onnxruntime_URL2 "https://hub.nuaa.cf/csukuangfj/onnxruntime-libs/releases/download/v1.17.1/onnxruntime-osx-universal2-static_lib-1.17.1.zip") +set(onnxruntime_URL2 "https://hf-mirror.com/csukuangfj/onnxruntime-libs/resolve/main/onnxruntime-osx-universal2-static_lib-1.17.1.zip") set(onnxruntime_HASH "SHA256=45599dbd2fb9dd52d6505930c0e82ca165391e222a68f5606b9ea9d4f3922e15") # If you don't have access to the Internet, diff --git a/cmake/onnxruntime-osx-universal.cmake b/cmake/onnxruntime-osx-universal.cmake index 2b0fbb110..fe5a53a63 100644 --- a/cmake/onnxruntime-osx-universal.cmake +++ b/cmake/onnxruntime-osx-universal.cmake @@ -14,7 +14,7 @@ if(NOT BUILD_SHARED_LIBS) endif() set(onnxruntime_URL "https://github.com/microsoft/onnxruntime/releases/download/v1.17.1/onnxruntime-osx-universal2-1.17.1.tgz") -set(onnxruntime_URL2 "https://hub.nuaa.cf/microsoft/onnxruntime/releases/download/v1.17.1/onnxruntime-osx-universal2-1.17.1.tgz") +set(onnxruntime_URL2 "https://hf-mirror.com/csukuangfj/onnxruntime-libs/resolve/main/onnxruntime-osx-universal2-1.17.1.tgz") set(onnxruntime_HASH "SHA256=9fa57fa6f202a373599377ef75064ae568fda8da838632b26a86024c7378d306") # If you don't have access to the Internet, diff --git a/cmake/onnxruntime-osx-x86_64-static.cmake b/cmake/onnxruntime-osx-x86_64-static.cmake index 259ec4d01..a3c98e709 100644 --- a/cmake/onnxruntime-osx-x86_64-static.cmake +++ b/cmake/onnxruntime-osx-x86_64-static.cmake @@ -13,7 +13,7 @@ if(BUILD_SHARED_LIBS) endif() set(onnxruntime_URL "https://github.com/csukuangfj/onnxruntime-libs/releases/download/v1.17.1/onnxruntime-osx-x86_64-static_lib-1.17.1.zip") -set(onnxruntime_URL2 "https://hub.nuaa.cf/csukuangfj/onnxruntime-libs/releases/download/v1.17.1/onnxruntime-osx-x86_64-static_lib-1.17.1.zip") +set(onnxruntime_URL2 "https://hf-mirror.com/csukuangfj/onnxruntime-libs/resolve/main/onnxruntime-osx-x86_64-static_lib-1.17.1.zip") set(onnxruntime_HASH "SHA256=5ff8efb97e50e257943c6c588328d2c57b649278098d3b468036f02755b60903") # If you don't have access to the Internet, diff --git a/cmake/onnxruntime-osx-x86_64.cmake b/cmake/onnxruntime-osx-x86_64.cmake index 81b78991a..4ca967460 100644 --- a/cmake/onnxruntime-osx-x86_64.cmake +++ b/cmake/onnxruntime-osx-x86_64.cmake @@ -13,7 +13,7 @@ if(NOT BUILD_SHARED_LIBS) endif() set(onnxruntime_URL "https://github.com/microsoft/onnxruntime/releases/download/v1.17.1/onnxruntime-osx-x86_64-1.17.1.tgz") -set(onnxruntime_URL2 "https://hub.nuaa.cf/microsoft/onnxruntime/releases/download/v1.17.1/onnxruntime-osx-x86_64-1.17.1.tgz") +set(onnxruntime_URL2 "https://hf-mirror.com/csukuangfj/onnxruntime-libs/resolve/main/onnxruntime-osx-x86_64-1.17.1.tgz") set(onnxruntime_HASH "SHA256=86c6b6896434084ff5086eebc4e9ea90be1ed4d46743f92864f46ee43e7b5059") # If you don't have access to the Internet, diff --git a/cmake/onnxruntime-wasm-simd.cmake b/cmake/onnxruntime-wasm-simd.cmake index dcc8fb5dd..19ac0411c 100644 --- a/cmake/onnxruntime-wasm-simd.cmake +++ b/cmake/onnxruntime-wasm-simd.cmake @@ -11,7 +11,7 @@ if(BUILD_SHARED_LIBS) endif() set(onnxruntime_URL "https://github.com/csukuangfj/onnxruntime-libs/releases/download/v1.17.1/onnxruntime-wasm-static_lib-simd-1.17.1.zip") -set(onnxruntime_URL2 "https://hub.nuaa.cf/csukuangfj/onnxruntime-libs/releases/download/v1.17.1/onnxruntime-wasm-static_lib-simd-1.17.1.zip") +set(onnxruntime_URL2 "https://hf-mirror.com/csukuangfj/onnxruntime-libs/resolve/main/onnxruntime-wasm-static_lib-simd-1.17.1.zip") set(onnxruntime_HASH "SHA256=8f07778e4233cf5a61a9d0795d90c5497177fbe8a46b701fda2d8d4e2b11cef8") # If you don't have access to the Internet, diff --git a/cmake/onnxruntime-win-arm64.cmake b/cmake/onnxruntime-win-arm64.cmake index 0705b6451..a4f247e34 100644 --- a/cmake/onnxruntime-win-arm64.cmake +++ b/cmake/onnxruntime-win-arm64.cmake @@ -16,7 +16,7 @@ if(NOT BUILD_SHARED_LIBS) endif() set(onnxruntime_URL "https://github.com/microsoft/onnxruntime/releases/download/v1.17.1/onnxruntime-win-arm64-1.17.1.zip") -set(onnxruntime_URL2 "https://hub.nuaa.cf/microsoft/onnxruntime/releases/download/v1.17.1/onnxruntime-win-arm64-1.17.1.zip") +set(onnxruntime_URL2 "https://hf-mirror.com/csukuangfj/onnxruntime-libs/resolve/main/onnxruntime-win-arm64-1.17.1.zip") set(onnxruntime_HASH "SHA256=47782cebcab0fd7a1f0a3f0676b088c1bc0f4fbf21666f6fe57570dc362fa5a8") # If you don't have access to the Internet, diff --git a/cmake/onnxruntime-win-x64-directml.cmake b/cmake/onnxruntime-win-x64-directml.cmake index 9648ffecc..a171a69a7 100644 --- a/cmake/onnxruntime-win-x64-directml.cmake +++ b/cmake/onnxruntime-win-x64-directml.cmake @@ -20,7 +20,7 @@ if(NOT SHERPA_ONNX_ENABLE_DIRECTML) endif() set(onnxruntime_URL "https://globalcdn.nuget.org/packages/microsoft.ml.onnxruntime.directml.1.14.1.nupkg") -set(onnxruntime_URL2 "https://huggingface.co/csukuangfj/sherpa-onnx-cmake-deps/resolve/main/microsoft.ml.onnxruntime.directml.1.14.1.nupkg") +set(onnxruntime_URL2 "https://hf-mirror.com/csukuangfj/sherpa-onnx-cmake-deps/resolve/main/microsoft.ml.onnxruntime.directml.1.14.1.nupkg") set(onnxruntime_HASH "SHA256=c8ae7623385b19cd5de968d0df5383e13b97d1b3a6771c9177eac15b56013a5a") # If you don't have access to the Internet, @@ -158,4 +158,4 @@ file(GLOB directml_lib_files "${directml_SOURCE_DIR}/bin/x64-win/DirectML.*") message(STATUS "DirectML lib files: ${directml_lib_files}") install(FILES ${directml_lib_files} DESTINATION lib) -install(FILES ${directml_lib_files} DESTINATION bin) \ No newline at end of file +install(FILES ${directml_lib_files} DESTINATION bin) diff --git a/cmake/onnxruntime-win-x64-gpu.cmake b/cmake/onnxruntime-win-x64-gpu.cmake index 18b64d01f..5265653a5 100644 --- a/cmake/onnxruntime-win-x64-gpu.cmake +++ b/cmake/onnxruntime-win-x64-gpu.cmake @@ -20,7 +20,7 @@ if(NOT SHERPA_ONNX_ENABLE_GPU) endif() set(onnxruntime_URL "https://github.com/microsoft/onnxruntime/releases/download/v1.17.1/onnxruntime-win-x64-gpu-1.17.1.zip") -set(onnxruntime_URL2 "https://hub.nuaa.cf/microsoft/onnxruntime/releases/download/v1.17.1/onnxruntime-win-x64-gpu-1.17.1.zip") +set(onnxruntime_URL2 "https://hf-mirror.com/csukuangfj/onnxruntime-libs/resolve/main/onnxruntime-win-x64-gpu-1.17.1.zip") set(onnxruntime_HASH "SHA256=b7a66f50ad146c2ccb43471d2d3b5ad78084c2d4ddbd3ea82d65f86c867408b2") # If you don't have access to the Internet, diff --git a/cmake/onnxruntime-win-x64-static-debug.cmake b/cmake/onnxruntime-win-x64-static-debug.cmake index 3281f4989..211873cf3 100644 --- a/cmake/onnxruntime-win-x64-static-debug.cmake +++ b/cmake/onnxruntime-win-x64-static-debug.cmake @@ -16,7 +16,7 @@ if(BUILD_SHARED_LIBS) endif() set(onnxruntime_URL "https://github.com/csukuangfj/onnxruntime-libs/releases/download/v1.17.1/onnxruntime-win-x64-static_lib-${CMAKE_BUILD_TYPE}-1.17.1.tar.bz2") -set(onnxruntime_URL2 "https://hub.nuaa.cf/csukuangfj/onnxruntime-libs/releases/download/v1.17.1/onnxruntime-win-x64-static_lib-${CMAKE_BUILD_TYPE}-1.17.1.tar.bz2") +set(onnxruntime_URL2 "https://hf-mirror.com/csukuangfj/onnxruntime-libs/resolve/main/onnxruntime-win-x64-static_lib-${CMAKE_BUILD_TYPE}-1.17.1.tar.bz2") if(CMAKE_BUILD_TYPE STREQUAL Debug) set(onnxruntime_HASH "SHA256=ecc68d914541c3b6ebc36148af63fe2a6af0f4f955b35199d612698d23169fa5") elseif(CMAKE_BUILD_TYPE STREQUAL RelWithDebInfo) diff --git a/cmake/onnxruntime-win-x64-static.cmake b/cmake/onnxruntime-win-x64-static.cmake index 009390872..811d64753 100644 --- a/cmake/onnxruntime-win-x64-static.cmake +++ b/cmake/onnxruntime-win-x64-static.cmake @@ -20,7 +20,7 @@ if(NOT CMAKE_BUILD_TYPE STREQUAL Release) endif() set(onnxruntime_URL "https://github.com/csukuangfj/onnxruntime-libs/releases/download/v1.17.1/onnxruntime-win-x64-static_lib-1.17.1.tar.bz2") -set(onnxruntime_URL2 "https://hub.nuaa.cf/github.com/csukuangfj/onnxruntime-libs/releases/download/v1.17.1/onnxruntime-win-x64-static_lib-1.17.1.tar.bz2") +set(onnxruntime_URL2 "https://hf-mirror.com/csukuangfj/onnxruntime-libs/resolve/main/onnxruntime-win-x64-static_lib-1.17.1.tar.bz2") set(onnxruntime_HASH "SHA256=42a0c02fda945d1d72433b2a7cdb2187d51cb4d7f3af462c6ae07b25314d5fb3") # If you don't have access to the Internet, diff --git a/cmake/onnxruntime-win-x64.cmake b/cmake/onnxruntime-win-x64.cmake index 26f96fdb0..4dbe0caa6 100644 --- a/cmake/onnxruntime-win-x64.cmake +++ b/cmake/onnxruntime-win-x64.cmake @@ -16,7 +16,7 @@ if(NOT BUILD_SHARED_LIBS) endif() set(onnxruntime_URL "https://github.com/microsoft/onnxruntime/releases/download/v1.17.1/onnxruntime-win-x64-1.17.1.zip") -set(onnxruntime_URL2 "https://hub.nuaa.cf/microsoft/onnxruntime/releases/download/v1.17.1/onnxruntime-win-x64-1.17.1.zip") +set(onnxruntime_URL2 "https://hf-mirror.com/csukuangfj/onnxruntime-libs/resolve/main/onnxruntime-win-x64-1.17.1.zip") set(onnxruntime_HASH "SHA256=4802af9598db02153d7da39432a48823ff69b2fb4b59155461937f20782aa91c") # If you don't have access to the Internet, diff --git a/cmake/onnxruntime-win-x86-static-debug.cmake b/cmake/onnxruntime-win-x86-static-debug.cmake index a8d6858c6..8f00f2a50 100644 --- a/cmake/onnxruntime-win-x86-static-debug.cmake +++ b/cmake/onnxruntime-win-x86-static-debug.cmake @@ -17,7 +17,7 @@ endif() set(onnxruntime_URL "https://github.com/csukuangfj/onnxruntime-libs/releases/download/v1.17.1/onnxruntime-win-x86-static_lib-${CMAKE_BUILD_TYPE}-1.17.1.tar.bz2") -set(onnxruntime_URL2 "https://hub.nuaa.cf/csukuangfj/onnxruntime-libs/releases/download/v1.17.1/onnxruntime-win-x86-static_lib-${CMAKE_BUILD_TYPE}-1.17.1.tar.bz2") +set(onnxruntime_URL2 "https://hf-mirror.com/csukuangfj/onnxruntime-libs/resolve/main/onnxruntime-win-x86-static_lib-${CMAKE_BUILD_TYPE}-1.17.1.tar.bz2") if(CMAKE_BUILD_TYPE STREQUAL Debug) set(onnxruntime_HASH "SHA256=b08b223fe09a5640472eec487ff42e4df6bf726e8aba9de40f443a1fabea3334") elseif(CMAKE_BUILD_TYPE STREQUAL RelWithDebInfo) diff --git a/cmake/onnxruntime-win-x86-static.cmake b/cmake/onnxruntime-win-x86-static.cmake index 7e291a616..ce424ee8c 100644 --- a/cmake/onnxruntime-win-x86-static.cmake +++ b/cmake/onnxruntime-win-x86-static.cmake @@ -20,7 +20,7 @@ if(NOT CMAKE_BUILD_TYPE STREQUAL Release) endif() set(onnxruntime_URL "https://github.com/csukuangfj/onnxruntime-libs/releases/download/v1.17.1/onnxruntime-win-x86-static_lib-1.17.1.tar.bz2") -set(onnxruntime_URL2 "https://hub.nuaa.cf/csukuangfj/onnxruntime-libs/releases/download/v1.17.1/onnxruntime-win-x86-static_lib-1.17.1.tar.bz2") +set(onnxruntime_URL2 "https://hf-mirror.com/csukuangfj/onnxruntime-libs/resolve/main/onnxruntime-win-x86-static_lib-1.17.1.tar.bz2") set(onnxruntime_HASH "SHA256=52375d3fabc7b437c955a664bfeb9cb7a6391f5219c4b7d3b87ff690416d4b9e") # If you don't have access to the Internet, diff --git a/cmake/onnxruntime-win-x86.cmake b/cmake/onnxruntime-win-x86.cmake index 99ed71653..cd8248300 100644 --- a/cmake/onnxruntime-win-x86.cmake +++ b/cmake/onnxruntime-win-x86.cmake @@ -16,7 +16,7 @@ if(NOT BUILD_SHARED_LIBS) endif() set(onnxruntime_URL "https://github.com/microsoft/onnxruntime/releases/download/v1.17.1/onnxruntime-win-x86-1.17.1.zip") -set(onnxruntime_URL2 "https://hub.nuaa.cf/microsoft/onnxruntime/releases/download/v1.17.1/onnxruntime-win-x86-1.17.1.zip") +set(onnxruntime_URL2 "https://hf-mirror.com/csukuangfj/onnxruntime-libs/resolve/main/onnxruntime-win-x86-1.17.1.zip") set(onnxruntime_HASH "SHA256=9404130825474bd36b2538ed925d6b5f2cf1fb6a443f3e125054ae3470019291") # If you don't have access to the Internet, diff --git a/cmake/openfst.cmake b/cmake/openfst.cmake index 0f5863b7c..2309c2fbe 100644 --- a/cmake/openfst.cmake +++ b/cmake/openfst.cmake @@ -4,7 +4,7 @@ function(download_openfst) include(FetchContent) set(openfst_URL "https://github.com/csukuangfj/openfst/archive/refs/tags/sherpa-onnx-2024-06-19.tar.gz") - set(openfst_URL2 "https://hub.nuaa.cf/csukuangfj/openfst/archive/refs/tags/sherpa-onnx-2024-06-19.tar.gz") + set(openfst_URL2 "https://hf-mirror.com/csukuangfj/sherpa-onnx-cmake-deps/resolve/main/openfst-sherpa-onnx-2024-06-19.tar.gz") set(openfst_HASH "SHA256=5c98e82cc509c5618502dde4860b8ea04d843850ed57e6d6b590b644b268853d") # If you don't have access to the Internet, diff --git a/cmake/piper-phonemize.cmake b/cmake/piper-phonemize.cmake index 7ecf1791b..bcea4e8ac 100644 --- a/cmake/piper-phonemize.cmake +++ b/cmake/piper-phonemize.cmake @@ -2,7 +2,7 @@ function(download_piper_phonemize) include(FetchContent) set(piper_phonemize_URL "https://github.com/csukuangfj/piper-phonemize/archive/dc6b5f4441bffe521047086930b0fc12686acd56.zip") - set(piper_phonemize_URL2 "https://hub.nuaa.cf/csukuangfj/piper-phonemize/archive/dc6b5f4441bffe521047086930b0fc12686acd56.zip") + set(piper_phonemize_URL2 "https://hf-mirror.com/csukuangfj/sherpa-onnx-cmake-deps/resolve/main/piper-phonemize-dc6b5f4441bffe521047086930b0fc12686acd56.zip") set(piper_phonemize_HASH "SHA256=b9faa04204b1756fa455a962abb1f037041c040133d55be58d11f11ab9b3ce14") # If you don't have access to the Internet, diff --git a/cmake/pybind11.cmake b/cmake/pybind11.cmake index 0d4894eff..fe69ccc5a 100644 --- a/cmake/pybind11.cmake +++ b/cmake/pybind11.cmake @@ -2,7 +2,7 @@ function(download_pybind11) include(FetchContent) set(pybind11_URL "https://github.com/pybind/pybind11/archive/refs/tags/v2.10.2.tar.gz") - set(pybind11_URL2 "https://hub.nuaa.cf/pybind/pybind11/archive/refs/tags/v2.10.2.tar.gz") + set(pybind11_URL2 "https://hf-mirror.com/csukuangfj/sherpa-onnx-cmake-deps/resolve/main/pybind11-2.10.2.tar.gz") set(pybind11_HASH "SHA256=93bd1e625e43e03028a3ea7389bba5d3f9f2596abc074b068e70f4ef9b1314ae") # If you don't have access to the Internet, diff --git a/cmake/simple-sentencepiece.cmake b/cmake/simple-sentencepiece.cmake index 09a640b11..4b6750d0f 100644 --- a/cmake/simple-sentencepiece.cmake +++ b/cmake/simple-sentencepiece.cmake @@ -2,7 +2,7 @@ function(download_simple_sentencepiece) include(FetchContent) set(simple-sentencepiece_URL "https://github.com/pkufool/simple-sentencepiece/archive/refs/tags/v0.7.tar.gz") - set(simple-sentencepiece_URL2 "https://hub.nuaa.cf/pkufool/simple-sentencepiece/archive/refs/tags/v0.7.tar.gz") + set(simple-sentencepiece_URL2 "https://hf-mirror.com/csukuangfj/sherpa-onnx-cmake-deps/resolve/main/simple-sentencepiece-0.7.tar.gz") set(simple-sentencepiece_HASH "SHA256=1748a822060a35baa9f6609f84efc8eb54dc0e74b9ece3d82367b7119fdc75af") # If you don't have access to the Internet, diff --git a/cmake/websocketpp.cmake b/cmake/websocketpp.cmake index 6ae9b89a3..79b0585be 100644 --- a/cmake/websocketpp.cmake +++ b/cmake/websocketpp.cmake @@ -3,7 +3,7 @@ function(download_websocketpp) # The latest commit on the develop branch os as 2022-10-22 set(websocketpp_URL "https://github.com/zaphoyd/websocketpp/archive/b9aeec6eaf3d5610503439b4fae3581d9aff08e8.zip") - set(websocketpp_URL2 "https://hub.nuaa.cf/zaphoyd/websocketpp/archive/b9aeec6eaf3d5610503439b4fae3581d9aff08e8.zip") + set(websocketpp_URL2 "https://hf-mirror.com/csukuangfj/sherpa-onnx-cmake-deps/resolve/main/websocketpp-b9aeec6eaf3d5610503439b4fae3581d9aff08e8.zip") set(websocketpp_HASH "SHA256=1385135ede8191a7fbef9ec8099e3c5a673d48df0c143958216cd1690567f583") # If you don't have access to the Internet, diff --git a/ffmpeg-examples/sherpa-onnx-ffmpeg.c b/ffmpeg-examples/sherpa-onnx-ffmpeg.c index cf3614518..82cff1173 100644 --- a/ffmpeg-examples/sherpa-onnx-ffmpeg.c +++ b/ffmpeg-examples/sherpa-onnx-ffmpeg.c @@ -214,8 +214,8 @@ static int init_filters(const char *filters_descr) { } static void sherpa_decode_frame(const AVFrame *frame, - SherpaOnnxOnlineRecognizer *recognizer, - SherpaOnnxOnlineStream *stream, + const SherpaOnnxOnlineRecognizer *recognizer, + const SherpaOnnxOnlineStream *stream, const SherpaOnnxDisplay *display, int32_t *segment_id) { #define N 3200 // 100s. Sample rate is fixed to 16 kHz diff --git a/scripts/node-addon-api/src/non-streaming-asr.cc b/scripts/node-addon-api/src/non-streaming-asr.cc index 86badc0ff..28c0b31ed 100644 --- a/scripts/node-addon-api/src/non-streaming-asr.cc +++ b/scripts/node-addon-api/src/non-streaming-asr.cc @@ -340,7 +340,7 @@ static Napi::External CreateOfflineStreamWrapper( SherpaOnnxCreateOfflineStream(recognizer); return Napi::External::New( - env, const_cast(stream), + env, const_cast(stream), [](Napi::Env env, SherpaOnnxOfflineStream *stream) { SherpaOnnxDestroyOfflineStream(stream); }); diff --git a/scripts/node-addon-api/src/streaming-asr.cc b/scripts/node-addon-api/src/streaming-asr.cc index cb3aaac86..4652be5f5 100644 --- a/scripts/node-addon-api/src/streaming-asr.cc +++ b/scripts/node-addon-api/src/streaming-asr.cc @@ -312,10 +312,12 @@ static Napi::External CreateOnlineStreamWrapper( SherpaOnnxOnlineRecognizer *recognizer = info[0].As>().Data(); - SherpaOnnxOnlineStream *stream = SherpaOnnxCreateOnlineStream(recognizer); + const SherpaOnnxOnlineStream *stream = + SherpaOnnxCreateOnlineStream(recognizer); return Napi::External::New( - env, stream, [](Napi::Env env, SherpaOnnxOnlineStream *stream) { + env, const_cast(stream), + [](Napi::Env env, SherpaOnnxOnlineStream *stream) { SherpaOnnxDestroyOnlineStream(stream); }); } diff --git a/sherpa-onnx/c-api/cxx-api.h b/sherpa-onnx/c-api/cxx-api.h index b078f5c73..17727f817 100644 --- a/sherpa-onnx/c-api/cxx-api.h +++ b/sherpa-onnx/c-api/cxx-api.h @@ -16,22 +16,22 @@ namespace sherpa_onnx::cxx { // ============================================================================ // Streaming ASR // ============================================================================ -struct SHERPA_ONNX_API OnlineTransducerModelConfig { +struct OnlineTransducerModelConfig { std::string encoder; std::string decoder; std::string joiner; }; -struct SHERPA_ONNX_API OnlineParaformerModelConfig { +struct OnlineParaformerModelConfig { std::string encoder; std::string decoder; }; -struct SHERPA_ONNX_API OnlineZipformer2CtcModelConfig { +struct OnlineZipformer2CtcModelConfig { std::string model; }; -struct SHERPA_ONNX_API OnlineModelConfig { +struct OnlineModelConfig { OnlineTransducerModelConfig transducer; OnlineParaformerModelConfig paraformer; OnlineZipformer2CtcModelConfig zipformer2_ctc; @@ -45,17 +45,17 @@ struct SHERPA_ONNX_API OnlineModelConfig { std::string tokens_buf; }; -struct SHERPA_ONNX_API FeatureConfig { +struct FeatureConfig { int32_t sample_rate = 16000; int32_t feature_dim = 80; }; -struct SHERPA_ONNX_API OnlineCtcFstDecoderConfig { +struct OnlineCtcFstDecoderConfig { std::string graph; int32_t max_active = 3000; }; -struct SHERPA_ONNX_API OnlineRecognizerConfig { +struct OnlineRecognizerConfig { FeatureConfig feat_config; OnlineModelConfig model_config; @@ -83,14 +83,14 @@ struct SHERPA_ONNX_API OnlineRecognizerConfig { std::string hotwords_buf; }; -struct SHERPA_ONNX_API OnlineRecognizerResult { +struct OnlineRecognizerResult { std::string text; std::vector tokens; std::vector timestamps; std::string json; }; -struct SHERPA_ONNX_API Wave { +struct Wave { std::vector samples; int32_t sample_rate; }; @@ -118,6 +118,8 @@ class SHERPA_ONNX_API MoveOnly { Destroy(); p_ = other.Release(); + + return *this; } const T *Get() const { return p_; } diff --git a/sherpa-onnx/csrc/CMakeLists.txt b/sherpa-onnx/csrc/CMakeLists.txt index 3e6526563..fafe5de96 100644 --- a/sherpa-onnx/csrc/CMakeLists.txt +++ b/sherpa-onnx/csrc/CMakeLists.txt @@ -18,6 +18,7 @@ set(sources endpoint.cc features.cc file-utils.cc + fst-utils.cc hypothesis.cc keyword-spotter-impl.cc keyword-spotter.cc diff --git a/sherpa-onnx/csrc/fst-utils.cc b/sherpa-onnx/csrc/fst-utils.cc new file mode 100644 index 000000000..5fcf5235a --- /dev/null +++ b/sherpa-onnx/csrc/fst-utils.cc @@ -0,0 +1,53 @@ +// sherpa-onnx/csrc/fst-utils.cc +// +// Copyright (c) 2024 Xiaomi Corporation + +#include "sherpa-onnx/csrc/fst-utils.h" + +#include "sherpa-onnx/csrc/macros.h" + +namespace sherpa_onnx { + +// This function is copied from kaldi. +// +// @param filename Path to a StdVectorFst or StdConstFst graph +// @return The caller should free the returned pointer using `delete` to +// avoid memory leak. +fst::Fst *ReadGraph(const std::string &filename) { + // read decoding network FST + std::ifstream is(filename, std::ios::binary); + if (!is.good()) { + SHERPA_ONNX_LOGE("Could not open decoding-graph FST %s", filename.c_str()); + } + + fst::FstHeader hdr; + if (!hdr.Read(is, "")) { + SHERPA_ONNX_LOGE("Reading FST: error reading FST header."); + } + + if (hdr.ArcType() != fst::StdArc::Type()) { + SHERPA_ONNX_LOGE("FST with arc type %s not supported", + hdr.ArcType().c_str()); + } + fst::FstReadOptions ropts("", &hdr); + + fst::Fst *decode_fst = nullptr; + + if (hdr.FstType() == "vector") { + decode_fst = fst::VectorFst::Read(is, ropts); + } else if (hdr.FstType() == "const") { + decode_fst = fst::ConstFst::Read(is, ropts); + } else { + SHERPA_ONNX_LOGE("Reading FST: unsupported FST type: %s", + hdr.FstType().c_str()); + } + + if (decode_fst == nullptr) { // fst code will warn. + SHERPA_ONNX_LOGE("Error reading FST (after reading header)."); + return nullptr; + } else { + return decode_fst; + } +} + +} // namespace sherpa_onnx diff --git a/sherpa-onnx/csrc/fst-utils.h b/sherpa-onnx/csrc/fst-utils.h new file mode 100644 index 000000000..92e6a7aad --- /dev/null +++ b/sherpa-onnx/csrc/fst-utils.h @@ -0,0 +1,18 @@ +// sherpa-onnx/csrc/fst-utils.h +// +// Copyright (c) 2024 Xiaomi Corporation + +#ifndef SHERPA_ONNX_CSRC_FST_UTILS_H_ +#define SHERPA_ONNX_CSRC_FST_UTILS_H_ + +#include + +#include "fst/fstlib.h" + +namespace sherpa_onnx { + +fst::Fst *ReadGraph(const std::string &filename); + +} + +#endif // SHERPA_ONNX_CSRC_FST_UTILS_H_ diff --git a/sherpa-onnx/csrc/jieba-lexicon.cc b/sherpa-onnx/csrc/jieba-lexicon.cc index e62324103..e995c8cb8 100644 --- a/sherpa-onnx/csrc/jieba-lexicon.cc +++ b/sherpa-onnx/csrc/jieba-lexicon.cc @@ -10,18 +10,12 @@ #include "cppjieba/Jieba.hpp" #include "sherpa-onnx/csrc/file-utils.h" +#include "sherpa-onnx/csrc/lexicon.h" #include "sherpa-onnx/csrc/macros.h" #include "sherpa-onnx/csrc/text-utils.h" namespace sherpa_onnx { -// implemented in ./lexicon.cc -std::unordered_map ReadTokens(std::istream &is); - -std::vector ConvertTokensToIds( - const std::unordered_map &token2id, - const std::vector &tokens); - class JiebaLexicon::Impl { public: Impl(const std::string &lexicon, const std::string &tokens, diff --git a/sherpa-onnx/csrc/lexicon.h b/sherpa-onnx/csrc/lexicon.h index 2c71ab7e8..9c2d91ee9 100644 --- a/sherpa-onnx/csrc/lexicon.h +++ b/sherpa-onnx/csrc/lexicon.h @@ -6,6 +6,7 @@ #define SHERPA_ONNX_CSRC_LEXICON_H_ #include +#include #include #include #include @@ -66,6 +67,12 @@ class Lexicon : public OfflineTtsFrontend { bool debug_ = false; }; +std::unordered_map ReadTokens(std::istream &is); + +std::vector ConvertTokensToIds( + const std::unordered_map &token2id, + const std::vector &tokens); + } // namespace sherpa_onnx #endif // SHERPA_ONNX_CSRC_LEXICON_H_ diff --git a/sherpa-onnx/csrc/melo-tts-lexicon.cc b/sherpa-onnx/csrc/melo-tts-lexicon.cc index e379b9c2f..d7332b36c 100644 --- a/sherpa-onnx/csrc/melo-tts-lexicon.cc +++ b/sherpa-onnx/csrc/melo-tts-lexicon.cc @@ -10,18 +10,12 @@ #include "cppjieba/Jieba.hpp" #include "sherpa-onnx/csrc/file-utils.h" +#include "sherpa-onnx/csrc/lexicon.h" #include "sherpa-onnx/csrc/macros.h" #include "sherpa-onnx/csrc/text-utils.h" namespace sherpa_onnx { -// implemented in ./lexicon.cc -std::unordered_map ReadTokens(std::istream &is); - -std::vector ConvertTokensToIds( - const std::unordered_map &token2id, - const std::vector &tokens); - class MeloTtsLexicon::Impl { public: Impl(const std::string &lexicon, const std::string &tokens, diff --git a/sherpa-onnx/csrc/offline-ctc-fst-decoder.cc b/sherpa-onnx/csrc/offline-ctc-fst-decoder.cc index 6c9df3fd3..ca3dcaee9 100644 --- a/sherpa-onnx/csrc/offline-ctc-fst-decoder.cc +++ b/sherpa-onnx/csrc/offline-ctc-fst-decoder.cc @@ -11,52 +11,11 @@ #include "kaldi-decoder/csrc/decodable-ctc.h" #include "kaldi-decoder/csrc/eigen.h" #include "kaldi-decoder/csrc/faster-decoder.h" +#include "sherpa-onnx/csrc/fst-utils.h" #include "sherpa-onnx/csrc/macros.h" namespace sherpa_onnx { -// This function is copied from kaldi. -// -// @param filename Path to a StdVectorFst or StdConstFst graph -// @return The caller should free the returned pointer using `delete` to -// avoid memory leak. -fst::Fst *ReadGraph(const std::string &filename) { - // read decoding network FST - std::ifstream is(filename, std::ios::binary); - if (!is.good()) { - SHERPA_ONNX_LOGE("Could not open decoding-graph FST %s", filename.c_str()); - } - - fst::FstHeader hdr; - if (!hdr.Read(is, "")) { - SHERPA_ONNX_LOGE("Reading FST: error reading FST header."); - } - - if (hdr.ArcType() != fst::StdArc::Type()) { - SHERPA_ONNX_LOGE("FST with arc type %s not supported", - hdr.ArcType().c_str()); - } - fst::FstReadOptions ropts("", &hdr); - - fst::Fst *decode_fst = nullptr; - - if (hdr.FstType() == "vector") { - decode_fst = fst::VectorFst::Read(is, ropts); - } else if (hdr.FstType() == "const") { - decode_fst = fst::ConstFst::Read(is, ropts); - } else { - SHERPA_ONNX_LOGE("Reading FST: unsupported FST type: %s", - hdr.FstType().c_str()); - } - - if (decode_fst == nullptr) { // fst code will warn. - SHERPA_ONNX_LOGE("Error reading FST (after reading header)."); - return nullptr; - } else { - return decode_fst; - } -} - /** * @param decoder * @param p Pointer to a 2-d array of shape (num_frames, vocab_size) diff --git a/sherpa-onnx/csrc/offline-speaker-diarization-result.cc b/sherpa-onnx/csrc/offline-speaker-diarization-result.cc index 8bf83f5d9..596957288 100644 --- a/sherpa-onnx/csrc/offline-speaker-diarization-result.cc +++ b/sherpa-onnx/csrc/offline-speaker-diarization-result.cc @@ -5,6 +5,7 @@ #include "sherpa-onnx/csrc/offline-speaker-diarization-result.h" #include +#include #include #include #include @@ -48,11 +49,13 @@ OfflineSpeakerDiarizationSegment::Merge( } std::string OfflineSpeakerDiarizationSegment::ToString() const { - char s[128]; - snprintf(s, sizeof(s), "%.3f -- %.3f speaker_%02d", start_, end_, speaker_); + std::array s{}; + + snprintf(s.data(), s.size(), "%.3f -- %.3f speaker_%02d", start_, end_, + speaker_); std::ostringstream os; - os << s; + os << s.data(); if (!text_.empty()) { os << " " << text_; diff --git a/sherpa-onnx/csrc/offline-speaker-diarization.cc b/sherpa-onnx/csrc/offline-speaker-diarization.cc index f34ea4e0e..a4b021b73 100644 --- a/sherpa-onnx/csrc/offline-speaker-diarization.cc +++ b/sherpa-onnx/csrc/offline-speaker-diarization.cc @@ -5,6 +5,7 @@ #include "sherpa-onnx/csrc/offline-speaker-diarization.h" #include +#include #include "sherpa-onnx/csrc/offline-speaker-diarization-impl.h" @@ -94,7 +95,7 @@ OfflineSpeakerDiarizationResult OfflineSpeakerDiarization::Process( const float *audio, int32_t n, OfflineSpeakerDiarizationProgressCallback callback /*= nullptr*/, void *callback_arg /*= nullptr*/) const { - return impl_->Process(audio, n, callback, callback_arg); + return impl_->Process(audio, n, std::move(callback), callback_arg); } } // namespace sherpa_onnx diff --git a/sherpa-onnx/csrc/online-ctc-fst-decoder.cc b/sherpa-onnx/csrc/online-ctc-fst-decoder.cc index 95e16ba75..dea909183 100644 --- a/sherpa-onnx/csrc/online-ctc-fst-decoder.cc +++ b/sherpa-onnx/csrc/online-ctc-fst-decoder.cc @@ -13,14 +13,12 @@ #include "fst/fstlib.h" #include "kaldi-decoder/csrc/decodable-ctc.h" #include "kaldifst/csrc/fstext-utils.h" +#include "sherpa-onnx/csrc/fst-utils.h" #include "sherpa-onnx/csrc/macros.h" #include "sherpa-onnx/csrc/online-stream.h" namespace sherpa_onnx { -// defined in ./offline-ctc-fst-decoder.cc -fst::Fst *ReadGraph(const std::string &filename); - OnlineCtcFstDecoder::OnlineCtcFstDecoder( const OnlineCtcFstDecoderConfig &config, int32_t blank_id) : config_(config), fst_(ReadGraph(config.graph)), blank_id_(blank_id) { diff --git a/sherpa-onnx/csrc/online-recognizer.cc b/sherpa-onnx/csrc/online-recognizer.cc index c6b9399d8..ba7cba8ec 100644 --- a/sherpa-onnx/csrc/online-recognizer.cc +++ b/sherpa-onnx/csrc/online-recognizer.cc @@ -19,6 +19,8 @@ namespace sherpa_onnx { +namespace { + /// Helper for `OnlineRecognizerResult::AsJsonString()` template std::string VecToString(const std::vector &vec, int32_t precision = 6) { @@ -51,6 +53,8 @@ std::string VecToString(const std::vector &vec, return oss.str(); } +} // namespace + std::string OnlineRecognizerResult::AsJsonString() const { std::ostringstream os; os << "{ ";