Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -496,8 +496,6 @@ if(SHERPA_ONNX_ENABLE_WEBSOCKET)
endif()

if(SHERPA_ONNX_ENABLE_TTS)
include(cppinyin)

include(espeak-ng-for-piper)
set(ESPEAK_NG_DIR ${espeak_ng_SOURCE_DIR})
message(STATUS "ESPEAK_NG_DIR: ${ESPEAK_NG_DIR}")
Expand Down
4 changes: 1 addition & 3 deletions build-ios.sh
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ cmake --build build/os64 --target install
echo "Generate xcframework"

mkdir -p "build/simulator/lib"
for f in libcppinyin_core.a libkaldi-native-fbank-core.a libkissfft-float.a libsherpa-onnx-c-api.a libsherpa-onnx-core.a \
for f in libkaldi-native-fbank-core.a libkissfft-float.a libsherpa-onnx-c-api.a libsherpa-onnx-core.a \
libsherpa-onnx-fstfar.a libssentencepiece_core.a \
libsherpa-onnx-fst.a libsherpa-onnx-kaldifst-core.a libkaldi-decoder-core.a \
libucd.a libpiper_phonemize.a libespeak-ng.a; do
Expand All @@ -139,7 +139,6 @@ done
# Merge archive first, because the following xcodebuild create xcframework
# cannot accept multi archive with the same architecture.
libtool -static -o build/simulator/libsherpa-onnx.a \
build/simulator/lib/libcppinyin_core.a \
build/simulator/lib/libkaldi-native-fbank-core.a \
build/simulator/lib/libkissfft-float.a \
build/simulator/lib/libsherpa-onnx-c-api.a \
Expand All @@ -154,7 +153,6 @@ libtool -static -o build/simulator/libsherpa-onnx.a \
build/simulator/lib/libssentencepiece_core.a

libtool -static -o build/os64/libsherpa-onnx.a \
build/os64/lib/libcppinyin_core.a \
build/os64/lib/libkaldi-native-fbank-core.a \
build/os64/lib/libkissfft-float.a \
build/os64/lib/libsherpa-onnx-c-api.a \
Expand Down
1 change: 0 additions & 1 deletion build-swift-macos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ make install
rm -fv ./install/include/cargs.h

libtool -static -o ./install/lib/libsherpa-onnx.a \
./install/lib/libcppinyin_core.a \
./install/lib/libsherpa-onnx-c-api.a \
./install/lib/libsherpa-onnx-core.a \
./install/lib/libkaldi-native-fbank-core.a \
Expand Down
2 changes: 1 addition & 1 deletion c-api-examples/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ CUR_DIR :=$(shell pwd)
CFLAGS := -I ../ -I ../build/_deps/cargs-src/include/
LDFLAGS := -L ../build/lib
LDFLAGS += -L ../build/_deps/onnxruntime-src/lib
LDFLAGS += -lsherpa-onnx-c-api -lsherpa-onnx-core -lkaldi-decoder-core -lsherpa-onnx-kaldifst-core -lsherpa-onnx-fstfar -lsherpa-onnx-fst -lkaldi-native-fbank-core -lkissfft-float -lpiper_phonemize -lespeak-ng -lucd -lcargs -lonnxruntime -lcppinyin_core
LDFLAGS += -lsherpa-onnx-c-api -lsherpa-onnx-core -lkaldi-decoder-core -lsherpa-onnx-kaldifst-core -lsherpa-onnx-fstfar -lsherpa-onnx-fst -lkaldi-native-fbank-core -lkissfft-float -lpiper_phonemize -lespeak-ng -lucd -lcargs -lonnxruntime
LDFLAGS += -framework Foundation
LDFLAGS += -lc++
LDFLAGS += -Wl,-rpath,${CUR_DIR}/../build/lib
Expand Down
82 changes: 0 additions & 82 deletions cmake/cppinyin.cmake

This file was deleted.

81 changes: 0 additions & 81 deletions cmake/cppinyin.patch

This file was deleted.

2 changes: 1 addition & 1 deletion cmake/sherpa-onnx-static.pc.in
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ Cflags: -I"${includedir}"
# Note: -lcargs is required only for the following file
# https://github.com/k2-fsa/sherpa-onnx/blob/master/c-api-examples/decode-file-c-api.c
# We add it here so that users don't need to specify -lcargs when compiling decode-file-c-api.c
Libs: -L"${libdir}" -lsherpa-onnx-c-api -lsherpa-onnx-core -lkaldi-decoder-core -lsherpa-onnx-kaldifst-core -lsherpa-onnx-fstfar -lsherpa-onnx-fst -lkaldi-native-fbank-core -lkissfft-float -lpiper_phonemize -lespeak-ng -lucd -lonnxruntime -lssentencepiece_core -lcppinyin_core -Wl,-rpath,${libdir} @SHERPA_ONNX_PKG_WITH_CARGS@ @SHERPA_ONNX_PKG_CONFIG_EXTRA_LIBS@
Libs: -L"${libdir}" -lsherpa-onnx-c-api -lsherpa-onnx-core -lkaldi-decoder-core -lsherpa-onnx-kaldifst-core -lsherpa-onnx-fstfar -lsherpa-onnx-fst -lkaldi-native-fbank-core -lkissfft-float -lpiper_phonemize -lespeak-ng -lucd -lonnxruntime -lssentencepiece_core -Wl,-rpath,${libdir} @SHERPA_ONNX_PKG_WITH_CARGS@ @SHERPA_ONNX_PKG_CONFIG_EXTRA_LIBS@
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
sherpa-onnx-fst.lib;
kaldi-native-fbank-core.lib;
kissfft-float.lib;
cppinyin_core.lib;
onnxruntime.lib;
piper_phonemize.lib;
espeak-ng.lib;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
sherpa-onnx-fst.lib;
kaldi-native-fbank-core.lib;
kissfft-float.lib;
cppinyin_core.lib;
onnxruntime.lib;
piper_phonemize.lib;
espeak-ng.lib;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
sherpa-onnx-fst.lib;
kaldi-native-fbank-core.lib;
kissfft-float.lib;
cppinyin_core.lib;
onnxruntime.lib;
piper_phonemize.lib;
espeak-ng.lib;
Expand Down
2 changes: 0 additions & 2 deletions sherpa-onnx/csrc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,6 @@ if(SHERPA_ONNX_ENABLE_TTS)
offline-tts-model-config.cc
offline-tts-vits-model-config.cc
offline-tts-vits-model.cc
offline-tts-zipvoice-frontend.cc
offline-tts-zipvoice-model-config.cc
offline-tts-zipvoice-model.cc
offline-tts.cc
Expand Down Expand Up @@ -417,7 +416,6 @@ target_link_libraries(sherpa-onnx-core fstfar fst)

if(SHERPA_ONNX_ENABLE_TTS)
target_link_libraries(sherpa-onnx-core
cppinyin_core
piper_phonemize)
endif()

Expand Down
33 changes: 21 additions & 12 deletions sherpa-onnx/csrc/matcha-tts-lexicon.cc
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,12 @@ std::vector<std::string> SplitTokensUTF8(const std::string &s) {
}

std::vector<std::string> ProcessPhonemes(
const std::vector<std::vector<char32_t>> &phonemes) {
const std::vector<std::vector<char32_t>> &phonemes, bool skip_replacement) {
auto tokens = ConvertPhonemesToUTF8(phonemes);
if (skip_replacement) {
return tokens;
}

std::string joined = Join(tokens);
std::string replaced = ApplyReplacements(joined);
return SplitTokensUTF8(replaced);
Expand All @@ -139,8 +143,8 @@ void CallPhonemizeEspeak(const std::string &text,
class MatchaTtsLexicon::Impl {
public:
Impl(const std::string &lexicon, const std::string &tokens,
const std::string &data_dir, bool debug)
: debug_(debug) {
const std::string &data_dir, bool debug, bool skip_replacement)
: debug_(debug), skip_replacement_(skip_replacement) {
if (lexicon.empty()) {
SHERPA_ONNX_LOGE("Please provide lexicon.txt for this model");
SHERPA_ONNX_EXIT(-1);
Expand All @@ -163,8 +167,8 @@ class MatchaTtsLexicon::Impl {

template <typename Manager>
Impl(Manager *mgr, const std::string &lexicon, const std::string &tokens,
const std::string &data_dir, bool debug)
: debug_(debug) {
const std::string &data_dir, bool debug, bool skip_replacement)
: debug_(debug), skip_replacement_(skip_replacement) {
if (lexicon.empty()) {
SHERPA_ONNX_LOGE("Please provide lexicon.txt for this model");
SHERPA_ONNX_EXIT(-1);
Expand Down Expand Up @@ -360,7 +364,7 @@ class MatchaTtsLexicon::Impl {
std::vector<std::vector<piper::Phoneme>> phonemes;
CallPhonemizeEspeak(w, config, &phonemes);

auto pp = ProcessPhonemes(phonemes);
auto pp = ProcessPhonemes(phonemes, skip_replacement_);

for (const auto &p : pp) {
if (token2id_.count(p)) {
Expand Down Expand Up @@ -477,20 +481,25 @@ class MatchaTtsLexicon::Impl {
std::unordered_map<int32_t, std::string> id2token_;

bool debug_ = false;
bool skip_replacement_ = false;
}; // namespace sherpa_onnx

MatchaTtsLexicon::~MatchaTtsLexicon() = default;

MatchaTtsLexicon::MatchaTtsLexicon(const std::string &lexicon,
const std::string &tokens,
const std::string &data_dir, bool debug)
: impl_(std::make_unique<Impl>(lexicon, tokens, data_dir, debug)) {}
const std::string &data_dir, bool debug,
bool skip_replacement)
: impl_(std::make_unique<Impl>(lexicon, tokens, data_dir, debug,
skip_replacement)) {}

template <typename Manager>
MatchaTtsLexicon::MatchaTtsLexicon(Manager *mgr, const std::string &lexicon,
const std::string &tokens,
const std::string &data_dir, bool debug)
: impl_(std::make_unique<Impl>(mgr, lexicon, tokens, data_dir, debug)) {}
const std::string &data_dir, bool debug,
bool skip_replacement)
: impl_(std::make_unique<Impl>(mgr, lexicon, tokens, data_dir, debug,
skip_replacement)) {}

std::vector<TokenIDs> MatchaTtsLexicon::ConvertTextToTokenIds(
const std::string &text, const std::string & /*unused_voice = ""*/) const {
Expand All @@ -502,15 +511,15 @@ template MatchaTtsLexicon::MatchaTtsLexicon(AAssetManager *mgr,
const std::string &lexicon,
const std::string &tokens,
const std::string &data_dir,
bool debug);
bool debug, bool skip_replacement);
#endif

#if __OHOS__
template MatchaTtsLexicon::MatchaTtsLexicon(NativeResourceManager *mgr,
const std::string &lexicon,
const std::string &tokens,
const std::string &data_dir,
bool debug);
bool debug, bool skip_replacement);
#endif

} // namespace sherpa_onnx
5 changes: 3 additions & 2 deletions sherpa-onnx/csrc/matcha-tts-lexicon.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@ class MatchaTtsLexicon : public OfflineTtsFrontend {
~MatchaTtsLexicon() override;

MatchaTtsLexicon(const std::string &lexicon, const std::string &tokens,
const std::string &data_dir, bool debug);
const std::string &data_dir, bool debug,
bool skip_replacement);

template <typename Manager>
MatchaTtsLexicon(Manager *mgr, const std::string &lexicon,
const std::string &tokens, const std::string &data_dir,
bool debug);
bool debug, bool skip_replacement);

std::vector<TokenIDs> ConvertTextToTokenIds(
const std::string &text,
Expand Down
4 changes: 2 additions & 2 deletions sherpa-onnx/csrc/offline-tts-matcha-impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ class OfflineTtsMatchaImpl : public OfflineTtsImpl {
if (meta_data.is_zh_en) {
frontend_ = std::make_unique<MatchaTtsLexicon>(
mgr, config_.model.matcha.lexicon, config_.model.matcha.tokens,
config_.model.matcha.data_dir, config_.model.debug);
config_.model.matcha.data_dir, config_.model.debug, false);
} else if (meta_data.jieba) {
frontend_ = std::make_unique<CharacterLexicon>(
mgr, config_.model.matcha.lexicon, config_.model.matcha.tokens,
Expand All @@ -407,7 +407,7 @@ class OfflineTtsMatchaImpl : public OfflineTtsImpl {
if (meta_data.is_zh_en) {
frontend_ = std::make_unique<MatchaTtsLexicon>(
config_.model.matcha.lexicon, config_.model.matcha.tokens,
config_.model.matcha.data_dir, config_.model.debug);
config_.model.matcha.data_dir, config_.model.debug, false);
} else if (meta_data.jieba) {
frontend_ = std::make_unique<CharacterLexicon>(
config_.model.matcha.lexicon, config_.model.matcha.tokens,
Expand Down
Loading
Loading