diff --git a/cmake/openfst.cmake b/cmake/openfst.cmake index cb0826a98..b6633437f 100644 --- a/cmake/openfst.cmake +++ b/cmake/openfst.cmake @@ -3,18 +3,18 @@ function(download_openfst) include(FetchContent) - set(openfst_URL "https://github.com/kkm000/openfst/archive/refs/tags/win/1.6.5.1.tar.gz") - set(openfst_URL2 "https://hub.nuaa.cf/kkm000/openfst/archive/refs/tags/win/1.6.5.1.tar.gz") - set(openfst_HASH "SHA256=02c49b559c3976a536876063369efc0e41ab374be1035918036474343877046e") + set(openfst_URL "https://github.com/csukuangfj/openfst/archive/792965fda2a3bc29f282321f527af0d6ba26fd22.zip") + set(openfst_URL2 "https://hub.nuaa.cf/csukuangfj/openfst/archive/792965fda2a3bc29f282321f527af0d6ba26fd22.zip") + set(openfst_HASH "SHA256=815d8acf555e4aaece294d6280ec209d0e9d91e0120e8406b24ff7124ecdbb26") # If you don't have access to the Internet, # please pre-download it set(possible_file_locations - $ENV{HOME}/Downloads/openfst-win-1.6.5.1.tar.gz - ${CMAKE_SOURCE_DIR}/openfst-win-1.6.5.1.tar.gz - ${CMAKE_BINARY_DIR}/openfst-win-1.6.5.1.tar.gz - /tmp/openfst-win-1.6.5.1.tar.gz - /star-fj/fangjun/download/github/openfst-win-1.6.5.1.tar.gz + $ENV{HOME}/Downloads/openfst-792965fda2a3bc29f282321f527af0d6ba26fd22.zip + ${CMAKE_SOURCE_DIR}/openfst-792965fda2a3bc29f282321f527af0d6ba26fd22.zip + ${CMAKE_BINARY_DIR}/openfst-792965fda2a3bc29f282321f527af0d6ba26fd22.zip + /tmp/openfst-792965fda2a3bc29f282321f527af0d6ba26fd22.zip + /star-fj/fangjun/download/github/openfst-792965fda2a3bc29f282321f527af0d6ba26fd22.zip ) foreach(f IN LISTS possible_file_locations) diff --git a/scripts/dotnet/generate.py b/scripts/dotnet/generate.py index 5268211b2..ed395f149 100755 --- a/scripts/dotnet/generate.py +++ b/scripts/dotnet/generate.py @@ -40,8 +40,8 @@ def process_linux(s): "libpiper_phonemize.so.1", "libsherpa-onnx-c-api.so", "libsherpa-onnx-core.so", - "libsherpa-onnx-fstfar.so.7", - "libsherpa-onnx-fst.so.6", + "libsherpa-onnx-fstfar.so.16", + "libsherpa-onnx-fst.so.16", "libsherpa-onnx-kaldifst-core.so", "libucd.so", ] @@ -69,8 +69,8 @@ def process_macos(s): "libpiper_phonemize.1.dylib", "libsherpa-onnx-c-api.dylib", "libsherpa-onnx-core.dylib", - "libsherpa-onnx-fstfar.7.dylib", - "libsherpa-onnx-fst.6.dylib", + "libsherpa-onnx-fstfar.16.dylib", + "libsherpa-onnx-fst.16.dylib", "libsherpa-onnx-kaldifst-core.dylib", "libucd.dylib", ] diff --git a/sherpa-onnx/csrc/offline-tts-vits-impl.h b/sherpa-onnx/csrc/offline-tts-vits-impl.h index f7ddd8e47..a873fd8f6 100644 --- a/sherpa-onnx/csrc/offline-tts-vits-impl.h +++ b/sherpa-onnx/csrc/offline-tts-vits-impl.h @@ -56,6 +56,9 @@ class OfflineTtsVitsImpl : public OfflineTtsImpl { } std::vector files; SplitStringToVector(config.rule_fars, ",", false, &files); + + tn_list_.reserve(files.size() + tn_list_.size()); + for (const auto &f : files) { if (config.model.debug) { SHERPA_ONNX_LOGE("rule far: %s", f.c_str()); @@ -96,6 +99,34 @@ class OfflineTtsVitsImpl : public OfflineTtsImpl { tn_list_.push_back(std::make_unique(is)); } } + + if (!config.rule_fars.empty()) { + std::vector files; + SplitStringToVector(config.rule_fars, ",", false, &files); + tn_list_.reserve(files.size() + tn_list_.size()); + + for (const auto &f : files) { + if (config.model.debug) { + SHERPA_ONNX_LOGE("rule far: %s", f.c_str()); + } + + auto buf = ReadFile(mgr, f); + + std::unique_ptr s( + new std::istrstream(buf.data(), buf.size())); + + std::unique_ptr> reader( + fst::FarReader::Open(std::move(s))); + + for (; !reader->Done(); reader->Next()) { + std::unique_ptr r( + fst::CastOrConvertToConstFst(reader->GetFst()->Copy())); + + tn_list_.push_back( + std::make_unique(std::move(r))); + } // for (; !reader->Done(); reader->Next()) + } // for (const auto &f : files) + } // if (!config.rule_fars.empty()) } #endif diff --git a/sherpa-onnx/python/csrc/offline-stream.cc b/sherpa-onnx/python/csrc/offline-stream.cc index 32c6e4149..80d54d6cf 100644 --- a/sherpa-onnx/python/csrc/offline-stream.cc +++ b/sherpa-onnx/python/csrc/offline-stream.cc @@ -4,6 +4,8 @@ #include "sherpa-onnx/python/csrc/offline-stream.h" +#include + #include "sherpa-onnx/csrc/offline-stream.h" namespace sherpa_onnx { diff --git a/sherpa-onnx/python/csrc/online-stream.cc b/sherpa-onnx/python/csrc/online-stream.cc index 208000657..688a64f91 100644 --- a/sherpa-onnx/python/csrc/online-stream.cc +++ b/sherpa-onnx/python/csrc/online-stream.cc @@ -4,6 +4,8 @@ #include "sherpa-onnx/python/csrc/online-stream.h" +#include + #include "sherpa-onnx/csrc/online-stream.h" namespace sherpa_onnx {