Fangjun Kuang
Committed by GitHub

Support Chinese heteronyms on Android for TTS. (#742)

... ... @@ -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)
... ...
... ... @@ -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",
]
... ...
... ... @@ -56,6 +56,9 @@ class OfflineTtsVitsImpl : public OfflineTtsImpl {
}
std::vector<std::string> 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<kaldifst::TextNormalizer>(is));
}
}
if (!config.rule_fars.empty()) {
std::vector<std::string> 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<std::istream> s(
new std::istrstream(buf.data(), buf.size()));
std::unique_ptr<fst::FarReader<fst::StdArc>> reader(
fst::FarReader<fst::StdArc>::Open(std::move(s)));
for (; !reader->Done(); reader->Next()) {
std::unique_ptr<fst::StdConstFst> r(
fst::CastOrConvertToConstFst(reader->GetFst()->Copy()));
tn_list_.push_back(
std::make_unique<kaldifst::TextNormalizer>(std::move(r)));
} // for (; !reader->Done(); reader->Next())
} // for (const auto &f : files)
} // if (!config.rule_fars.empty())
}
#endif
... ...
... ... @@ -4,6 +4,8 @@
#include "sherpa-onnx/python/csrc/offline-stream.h"
#include <vector>
#include "sherpa-onnx/csrc/offline-stream.h"
namespace sherpa_onnx {
... ...
... ... @@ -4,6 +4,8 @@
#include "sherpa-onnx/python/csrc/online-stream.h"
#include <vector>
#include "sherpa-onnx/csrc/online-stream.h"
namespace sherpa_onnx {
... ...