diff --git a/sherpa-onnx/c-api/c-api.cc b/sherpa-onnx/c-api/c-api.cc index a6ad0772e..166430da4 100644 --- a/sherpa-onnx/c-api/c-api.cc +++ b/sherpa-onnx/c-api/c-api.cc @@ -485,9 +485,9 @@ static sherpa_onnx::OfflineRecognizerConfig GetOfflineRecognizerConfig( if (config->model_config.debug) { #if __OHOS__ - SHERPA_ONNX_LOGE("%{public}s", recognizer_config.ToString().c_str()); + SHERPA_ONNX_LOGE("%{public}s\n", recognizer_config.ToString().c_str()); #else - SHERPA_ONNX_LOGE("%s", recognizer_config.ToString().c_str()); + SHERPA_ONNX_LOGE("%s\n", recognizer_config.ToString().c_str()); #endif } @@ -967,9 +967,9 @@ sherpa_onnx::VadModelConfig GetVadModelConfig( if (vad_config.debug) { #if __OHOS__ - SHERPA_ONNX_LOGE("%{public}s", vad_config.ToString().c_str()); + SHERPA_ONNX_LOGE("%{public}s\n", vad_config.ToString().c_str()); #else - SHERPA_ONNX_LOGE("%s", vad_config.ToString().c_str()); + SHERPA_ONNX_LOGE("%s\n", vad_config.ToString().c_str()); #endif } @@ -1053,7 +1053,7 @@ struct SherpaOnnxOfflineTts { std::unique_ptr impl; }; -SherpaOnnxOfflineTts *SherpaOnnxCreateOfflineTts( +static sherpa_onnx::OfflineTtsConfig GetOfflineTtsConfig( const SherpaOnnxOfflineTtsConfig *config) { sherpa_onnx::OfflineTtsConfig tts_config; @@ -1084,9 +1084,20 @@ SherpaOnnxOfflineTts *SherpaOnnxCreateOfflineTts( tts_config.max_num_sentences = SHERPA_ONNX_OR(config->max_num_sentences, 2); if (tts_config.model.debug) { +#if __OHOS__ + SHERPA_ONNX_LOGE("%{public}s\n", tts_config.ToString().c_str()); +#else SHERPA_ONNX_LOGE("%s\n", tts_config.ToString().c_str()); +#endif } + return tts_config; +} + +SherpaOnnxOfflineTts *SherpaOnnxCreateOfflineTts( + const SherpaOnnxOfflineTtsConfig *config) { + auto tts_config = GetOfflineTtsConfig(config); + if (!tts_config.Validate()) { SHERPA_ONNX_LOGE("Errors in config"); return nullptr; @@ -1908,6 +1919,7 @@ SherpaOnnxOfflineSpeakerDiarizationProcessWithCallbackNoArg( return ans; } +#endif #ifdef __OHOS__ @@ -1959,6 +1971,23 @@ SherpaOnnxVoiceActivityDetector *SherpaOnnxCreateVoiceActivityDetectorOHOS( return p; } -#endif -#endif +#if SHERPA_ONNX_ENABLE_TTS == 1 +SherpaOnnxOfflineTts *SherpaOnnxCreateOfflineTtsOHOS( + const SherpaOnnxOfflineTtsConfig *config, NativeResourceManager *mgr) { + if (!mgr) { + return SherpaOnnxCreateOfflineTts(config); + } + + auto tts_config = GetOfflineTtsConfig(config); + + SherpaOnnxOfflineTts *tts = new SherpaOnnxOfflineTts; + + tts->impl = std::make_unique(mgr, tts_config); + + return tts; +} + +#endif // #if SHERPA_ONNX_ENABLE_TTS == 1 + +#endif // #ifdef __OHOS__ diff --git a/sherpa-onnx/c-api/c-api.h b/sherpa-onnx/c-api/c-api.h index 5251413a8..e9cd5be0a 100644 --- a/sherpa-onnx/c-api/c-api.h +++ b/sherpa-onnx/c-api/c-api.h @@ -1558,6 +1558,9 @@ SHERPA_ONNX_API SherpaOnnxVoiceActivityDetector * SherpaOnnxCreateVoiceActivityDetectorOHOS( const SherpaOnnxVadModelConfig *config, float buffer_size_in_seconds, NativeResourceManager *mgr); + +SHERPA_ONNX_API SherpaOnnxOfflineTts *SherpaOnnxCreateOfflineTtsOHOS( + const SherpaOnnxOfflineTtsConfig *config, NativeResourceManager *mgr); #endif #if defined(__GNUC__) diff --git a/sherpa-onnx/csrc/lexicon.cc b/sherpa-onnx/csrc/lexicon.cc index 499f17f68..fe5e595b9 100644 --- a/sherpa-onnx/csrc/lexicon.cc +++ b/sherpa-onnx/csrc/lexicon.cc @@ -7,17 +7,19 @@ #include #include #include +#include #include +#include #include #if __ANDROID_API__ >= 9 -#include - #include "android/asset_manager.h" #include "android/asset_manager_jni.h" #endif -#include +#if __OHOS__ +#include "rawfile/raw_file_manager.h" +#endif #include "sherpa-onnx/csrc/macros.h" #include "sherpa-onnx/csrc/onnx-utils.h" @@ -110,8 +112,8 @@ Lexicon::Lexicon(const std::string &lexicon, const std::string &tokens, InitPunctuations(punctuations); } -#if __ANDROID_API__ >= 9 -Lexicon::Lexicon(AAssetManager *mgr, const std::string &lexicon, +template +Lexicon::Lexicon(Manager *mgr, const std::string &lexicon, const std::string &tokens, const std::string &punctuations, const std::string &language, bool debug /*= false*/ ) @@ -132,7 +134,6 @@ Lexicon::Lexicon(AAssetManager *mgr, const std::string &lexicon, InitPunctuations(punctuations); } -#endif std::vector Lexicon::ConvertTextToTokenIds( const std::string &text, const std::string & /*voice*/ /*= ""*/) const { @@ -371,4 +372,18 @@ void Lexicon::InitPunctuations(const std::string &punctuations) { } } +#if __ANDROID_API__ >= 9 +template Lexicon::Lexicon(AAssetManager *mgr, const std::string &lexicon, + const std::string &tokens, + const std::string &punctuations, + const std::string &language, bool debug = false); +#endif + +#if __OHOS__ +template Lexicon::Lexicon(NativeResourceManager *mgr, + const std::string &lexicon, const std::string &tokens, + const std::string &punctuations, + const std::string &language, bool debug = false); +#endif + } // namespace sherpa_onnx diff --git a/sherpa-onnx/csrc/lexicon.h b/sherpa-onnx/csrc/lexicon.h index fb60cdb7f..39329694b 100644 --- a/sherpa-onnx/csrc/lexicon.h +++ b/sherpa-onnx/csrc/lexicon.h @@ -13,11 +13,6 @@ #include #include -#if __ANDROID_API__ >= 9 -#include "android/asset_manager.h" -#include "android/asset_manager_jni.h" -#endif - #include "sherpa-onnx/csrc/offline-tts-frontend.h" namespace sherpa_onnx { @@ -31,11 +26,10 @@ class Lexicon : public OfflineTtsFrontend { const std::string &punctuations, const std::string &language, bool debug = false); -#if __ANDROID_API__ >= 9 - Lexicon(AAssetManager *mgr, const std::string &lexicon, - const std::string &tokens, const std::string &punctuations, - const std::string &language, bool debug = false); -#endif + template + Lexicon(Manager *mgr, const std::string &lexicon, const std::string &tokens, + const std::string &punctuations, const std::string &language, + bool debug = false); std::vector ConvertTextToTokenIds( const std::string &text, const std::string &voice = "") const override; diff --git a/sherpa-onnx/csrc/offline-tts-character-frontend.cc b/sherpa-onnx/csrc/offline-tts-character-frontend.cc index 72481e094..0806a9fa2 100644 --- a/sherpa-onnx/csrc/offline-tts-character-frontend.cc +++ b/sherpa-onnx/csrc/offline-tts-character-frontend.cc @@ -2,20 +2,24 @@ // // Copyright (c) 2023 Xiaomi Corporation -#if __ANDROID_API__ >= 9 -#include - -#include "android/asset_manager.h" -#include "android/asset_manager_jni.h" -#endif #include #include #include #include #include #include +#include #include +#if __ANDROID_API__ >= 9 +#include "android/asset_manager.h" +#include "android/asset_manager_jni.h" +#endif + +#if __OHOS__ +#include "rawfile/raw_file_manager.h" +#endif + #include "sherpa-onnx/csrc/macros.h" #include "sherpa-onnx/csrc/offline-tts-character-frontend.h" #include "sherpa-onnx/csrc/onnx-utils.h" @@ -82,9 +86,9 @@ OfflineTtsCharacterFrontend::OfflineTtsCharacterFrontend( token2id_ = ReadTokens(is); } -#if __ANDROID_API__ >= 9 +template OfflineTtsCharacterFrontend::OfflineTtsCharacterFrontend( - AAssetManager *mgr, const std::string &tokens, + Manager *mgr, const std::string &tokens, const OfflineTtsVitsModelMetaData &meta_data) : meta_data_(meta_data) { auto buf = ReadFile(mgr, tokens); @@ -92,8 +96,6 @@ OfflineTtsCharacterFrontend::OfflineTtsCharacterFrontend( token2id_ = ReadTokens(is); } -#endif - std::vector OfflineTtsCharacterFrontend::ConvertTextToTokenIds( const std::string &_text, const std::string & /*voice = ""*/) const { // see @@ -189,4 +191,18 @@ std::vector OfflineTtsCharacterFrontend::ConvertTextToTokenIds( return ans; } +#if __ANDROID_API__ >= 9 +template OfflineTtsCharacterFrontend::OfflineTtsCharacterFrontend( + AAssetManager *mgr, const std::string &tokens, + const OfflineTtsVitsModelMetaData &meta_data); + +#endif + +#if __OHOS__ +template OfflineTtsCharacterFrontend::OfflineTtsCharacterFrontend( + NativeResourceManager *mgr, const std::string &tokens, + const OfflineTtsVitsModelMetaData &meta_data); + +#endif + } // namespace sherpa_onnx diff --git a/sherpa-onnx/csrc/offline-tts-character-frontend.h b/sherpa-onnx/csrc/offline-tts-character-frontend.h index ffd2bb5f4..fcd2f6dd5 100644 --- a/sherpa-onnx/csrc/offline-tts-character-frontend.h +++ b/sherpa-onnx/csrc/offline-tts-character-frontend.h @@ -9,11 +9,6 @@ #include #include -#if __ANDROID_API__ >= 9 -#include "android/asset_manager.h" -#include "android/asset_manager_jni.h" -#endif - #include "sherpa-onnx/csrc/offline-tts-frontend.h" #include "sherpa-onnx/csrc/offline-tts-vits-model-metadata.h" @@ -24,11 +19,10 @@ class OfflineTtsCharacterFrontend : public OfflineTtsFrontend { OfflineTtsCharacterFrontend(const std::string &tokens, const OfflineTtsVitsModelMetaData &meta_data); -#if __ANDROID_API__ >= 9 - OfflineTtsCharacterFrontend(AAssetManager *mgr, const std::string &tokens, + template + OfflineTtsCharacterFrontend(Manager *mgr, const std::string &tokens, const OfflineTtsVitsModelMetaData &meta_data); -#endif /** Convert a string to token IDs. * * @param text The input text. diff --git a/sherpa-onnx/csrc/offline-tts-impl.cc b/sherpa-onnx/csrc/offline-tts-impl.cc index 063730db8..62b6eebba 100644 --- a/sherpa-onnx/csrc/offline-tts-impl.cc +++ b/sherpa-onnx/csrc/offline-tts-impl.cc @@ -6,6 +6,15 @@ #include +#if __ANDROID_API__ >= 9 +#include "android/asset_manager.h" +#include "android/asset_manager_jni.h" +#endif + +#if __OHOS__ +#include "rawfile/raw_file_manager.h" +#endif + #include "sherpa-onnx/csrc/offline-tts-vits-impl.h" namespace sherpa_onnx { @@ -16,12 +25,21 @@ std::unique_ptr OfflineTtsImpl::Create( return std::make_unique(config); } -#if __ANDROID_API__ >= 9 +template std::unique_ptr OfflineTtsImpl::Create( - AAssetManager *mgr, const OfflineTtsConfig &config) { + Manager *mgr, const OfflineTtsConfig &config) { // TODO(fangjun): Support other types return std::make_unique(mgr, config); } + +#if __ANDROID_API__ >= 9 +template std::unique_ptr OfflineTtsImpl::Create( + AAssetManager *mgr, const OfflineTtsConfig &config); +#endif + +#if __OHOS__ +template std::unique_ptr OfflineTtsImpl::Create( + NativeResourceManager *mgr, const OfflineTtsConfig &config); #endif } // namespace sherpa_onnx diff --git a/sherpa-onnx/csrc/offline-tts-impl.h b/sherpa-onnx/csrc/offline-tts-impl.h index 3c9e27b1b..db8b7162d 100644 --- a/sherpa-onnx/csrc/offline-tts-impl.h +++ b/sherpa-onnx/csrc/offline-tts-impl.h @@ -8,11 +8,6 @@ #include #include -#if __ANDROID_API__ >= 9 -#include "android/asset_manager.h" -#include "android/asset_manager_jni.h" -#endif - #include "sherpa-onnx/csrc/offline-tts.h" namespace sherpa_onnx { @@ -23,10 +18,9 @@ class OfflineTtsImpl { static std::unique_ptr Create(const OfflineTtsConfig &config); -#if __ANDROID_API__ >= 9 - static std::unique_ptr Create(AAssetManager *mgr, + template + static std::unique_ptr Create(Manager *mgr, const OfflineTtsConfig &config); -#endif virtual GeneratedAudio Generate( const std::string &text, int64_t sid = 0, float speed = 1.0, diff --git a/sherpa-onnx/csrc/offline-tts-vits-impl.h b/sherpa-onnx/csrc/offline-tts-vits-impl.h index 72b21a3b5..972303dd4 100644 --- a/sherpa-onnx/csrc/offline-tts-vits-impl.h +++ b/sherpa-onnx/csrc/offline-tts-vits-impl.h @@ -6,16 +6,10 @@ #include #include +#include #include #include -#if __ANDROID_API__ >= 9 -#include - -#include "android/asset_manager.h" -#include "android/asset_manager_jni.h" -#endif - #include "fst/extensions/far/far.h" #include "kaldifst/csrc/kaldi-fst-io.h" #include "kaldifst/csrc/text-normalizer.h" @@ -82,8 +76,8 @@ class OfflineTtsVitsImpl : public OfflineTtsImpl { } } -#if __ANDROID_API__ >= 9 - OfflineTtsVitsImpl(AAssetManager *mgr, const OfflineTtsConfig &config) + template + OfflineTtsVitsImpl(Manager *mgr, const OfflineTtsConfig &config) : config_(config), model_(std::make_unique(mgr, config.model)) { InitFrontend(mgr); @@ -130,7 +124,6 @@ class OfflineTtsVitsImpl : public OfflineTtsImpl { } // for (const auto &f : files) } // if (!config.rule_fars.empty()) } -#endif int32_t SampleRate() const override { return model_->GetMetaData().sample_rate; @@ -297,8 +290,8 @@ class OfflineTtsVitsImpl : public OfflineTtsImpl { } private: -#if __ANDROID_API__ >= 9 - void InitFrontend(AAssetManager *mgr) { + template + void InitFrontend(Manager *mgr) { const auto &meta_data = model_->GetMetaData(); if (meta_data.frontend == "characters") { @@ -323,7 +316,6 @@ class OfflineTtsVitsImpl : public OfflineTtsImpl { meta_data.punctuations, meta_data.language, config_.model.debug); } } -#endif void InitFrontend() { const auto &meta_data = model_->GetMetaData(); diff --git a/sherpa-onnx/csrc/offline-tts-vits-model.cc b/sherpa-onnx/csrc/offline-tts-vits-model.cc index 90e0993d6..38efc6204 100644 --- a/sherpa-onnx/csrc/offline-tts-vits-model.cc +++ b/sherpa-onnx/csrc/offline-tts-vits-model.cc @@ -9,6 +9,15 @@ #include #include +#if __ANDROID_API__ >= 9 +#include "android/asset_manager.h" +#include "android/asset_manager_jni.h" +#endif + +#if __OHOS__ +#include "rawfile/raw_file_manager.h" +#endif + #include "sherpa-onnx/csrc/macros.h" #include "sherpa-onnx/csrc/onnx-utils.h" #include "sherpa-onnx/csrc/session.h" @@ -26,8 +35,8 @@ class OfflineTtsVitsModel::Impl { Init(buf.data(), buf.size()); } -#if __ANDROID_API__ >= 9 - Impl(AAssetManager *mgr, const OfflineTtsModelConfig &config) + template + Impl(Manager *mgr, const OfflineTtsModelConfig &config) : config_(config), env_(ORT_LOGGING_LEVEL_ERROR), sess_opts_(GetSessionOptions(config)), @@ -35,7 +44,6 @@ class OfflineTtsVitsModel::Impl { auto buf = ReadFile(mgr, config.vits.model); Init(buf.data(), buf.size()); } -#endif Ort::Value Run(Ort::Value x, int64_t sid, float speed) { if (meta_data_.is_piper || meta_data_.is_coqui) { @@ -336,11 +344,10 @@ class OfflineTtsVitsModel::Impl { OfflineTtsVitsModel::OfflineTtsVitsModel(const OfflineTtsModelConfig &config) : impl_(std::make_unique(config)) {} -#if __ANDROID_API__ >= 9 -OfflineTtsVitsModel::OfflineTtsVitsModel(AAssetManager *mgr, +template +OfflineTtsVitsModel::OfflineTtsVitsModel(Manager *mgr, const OfflineTtsModelConfig &config) : impl_(std::make_unique(mgr, config)) {} -#endif OfflineTtsVitsModel::~OfflineTtsVitsModel() = default; @@ -359,4 +366,14 @@ const OfflineTtsVitsModelMetaData &OfflineTtsVitsModel::GetMetaData() const { return impl_->GetMetaData(); } +#if __ANDROID_API__ >= 9 +template OfflineTtsVitsModel::OfflineTtsVitsModel( + AAssetManager *mgr, const OfflineTtsModelConfig &config); +#endif + +#if __OHOS__ +template OfflineTtsVitsModel::OfflineTtsVitsModel( + NativeResourceManager *mgr, const OfflineTtsModelConfig &config); +#endif + } // namespace sherpa_onnx diff --git a/sherpa-onnx/csrc/offline-tts-vits-model.h b/sherpa-onnx/csrc/offline-tts-vits-model.h index 543963c9d..a880934ef 100644 --- a/sherpa-onnx/csrc/offline-tts-vits-model.h +++ b/sherpa-onnx/csrc/offline-tts-vits-model.h @@ -8,11 +8,6 @@ #include #include -#if __ANDROID_API__ >= 9 -#include "android/asset_manager.h" -#include "android/asset_manager_jni.h" -#endif - #include "onnxruntime_cxx_api.h" // NOLINT #include "sherpa-onnx/csrc/offline-tts-model-config.h" #include "sherpa-onnx/csrc/offline-tts-vits-model-metadata.h" @@ -24,9 +19,9 @@ class OfflineTtsVitsModel { ~OfflineTtsVitsModel(); explicit OfflineTtsVitsModel(const OfflineTtsModelConfig &config); -#if __ANDROID_API__ >= 9 - OfflineTtsVitsModel(AAssetManager *mgr, const OfflineTtsModelConfig &config); -#endif + + template + OfflineTtsVitsModel(Manager *mgr, const OfflineTtsModelConfig &config); /** Run the model. * diff --git a/sherpa-onnx/csrc/offline-tts.cc b/sherpa-onnx/csrc/offline-tts.cc index 12feda0b7..ec2c69523 100644 --- a/sherpa-onnx/csrc/offline-tts.cc +++ b/sherpa-onnx/csrc/offline-tts.cc @@ -7,6 +7,15 @@ #include #include +#if __ANDROID_API__ >= 9 +#include "android/asset_manager.h" +#include "android/asset_manager_jni.h" +#endif + +#if __OHOS__ +#include "rawfile/raw_file_manager.h" +#endif + #include "sherpa-onnx/csrc/file-utils.h" #include "sherpa-onnx/csrc/macros.h" #include "sherpa-onnx/csrc/offline-tts-impl.h" @@ -78,10 +87,9 @@ std::string OfflineTtsConfig::ToString() const { OfflineTts::OfflineTts(const OfflineTtsConfig &config) : impl_(OfflineTtsImpl::Create(config)) {} -#if __ANDROID_API__ >= 9 -OfflineTts::OfflineTts(AAssetManager *mgr, const OfflineTtsConfig &config) +template +OfflineTts::OfflineTts(Manager *mgr, const OfflineTtsConfig &config) : impl_(OfflineTtsImpl::Create(mgr, config)) {} -#endif OfflineTts::~OfflineTts() = default; @@ -95,4 +103,14 @@ int32_t OfflineTts::SampleRate() const { return impl_->SampleRate(); } int32_t OfflineTts::NumSpeakers() const { return impl_->NumSpeakers(); } +#if __ANDROID_API__ >= 9 +template OfflineTts::OfflineTts(AAssetManager *mgr, + const OfflineTtsConfig &config); +#endif + +#if __OHOS__ +template OfflineTts::OfflineTts(NativeResourceManager *mgr, + const OfflineTtsConfig &config); +#endif + } // namespace sherpa_onnx diff --git a/sherpa-onnx/csrc/offline-tts.h b/sherpa-onnx/csrc/offline-tts.h index 03a13a159..8399443c0 100644 --- a/sherpa-onnx/csrc/offline-tts.h +++ b/sherpa-onnx/csrc/offline-tts.h @@ -10,11 +10,6 @@ #include #include -#if __ANDROID_API__ >= 9 -#include "android/asset_manager.h" -#include "android/asset_manager_jni.h" -#endif - #include "sherpa-onnx/csrc/offline-tts-model-config.h" #include "sherpa-onnx/csrc/parse-options.h" @@ -69,9 +64,8 @@ class OfflineTts { ~OfflineTts(); explicit OfflineTts(const OfflineTtsConfig &config); -#if __ANDROID_API__ >= 9 - OfflineTts(AAssetManager *mgr, const OfflineTtsConfig &config); -#endif + template + OfflineTts(Manager *mgr, const OfflineTtsConfig &config); // @param text A string containing words separated by spaces // @param sid Speaker ID. Used only for multi-speaker models, e.g., models diff --git a/sherpa-onnx/csrc/piper-phonemize-lexicon.cc b/sherpa-onnx/csrc/piper-phonemize-lexicon.cc index de753db61..298274654 100644 --- a/sherpa-onnx/csrc/piper-phonemize-lexicon.cc +++ b/sherpa-onnx/csrc/piper-phonemize-lexicon.cc @@ -11,16 +11,19 @@ #include // NOLINT #include #include +#include #include #include #if __ANDROID_API__ >= 9 -#include - #include "android/asset_manager.h" #include "android/asset_manager_jni.h" #endif +#if __OHOS__ +#include "rawfile/raw_file_manager.h" +#endif + #include "espeak-ng/speak_lib.h" #include "phoneme_ids.hpp" #include "phonemize.hpp" @@ -196,9 +199,9 @@ PiperPhonemizeLexicon::PiperPhonemizeLexicon( InitEspeak(data_dir); } -#if __ANDROID_API__ >= 9 +template PiperPhonemizeLexicon::PiperPhonemizeLexicon( - AAssetManager *mgr, const std::string &tokens, const std::string &data_dir, + Manager *mgr, const std::string &tokens, const std::string &data_dir, const OfflineTtsVitsModelMetaData &meta_data) : meta_data_(meta_data) { { @@ -212,7 +215,6 @@ PiperPhonemizeLexicon::PiperPhonemizeLexicon( // data_dir. InitEspeak(data_dir); } -#endif std::vector PiperPhonemizeLexicon::ConvertTextToTokenIds( const std::string &text, const std::string &voice /*= ""*/) const { @@ -255,4 +257,16 @@ std::vector PiperPhonemizeLexicon::ConvertTextToTokenIds( return ans; } +#if __ANDROID_API__ >= 9 +template PiperPhonemizeLexicon::PiperPhonemizeLexicon( + AAssetManager *mgr, const std::string &tokens, const std::string &data_dir, + const OfflineTtsVitsModelMetaData &meta_data); +#endif + +#if __OHOS__ +template PiperPhonemizeLexicon::PiperPhonemizeLexicon( + NativeResourceManager *mgr, const std::string &tokens, + const std::string &data_dir, const OfflineTtsVitsModelMetaData &meta_data); +#endif + } // namespace sherpa_onnx diff --git a/sherpa-onnx/csrc/piper-phonemize-lexicon.h b/sherpa-onnx/csrc/piper-phonemize-lexicon.h index 34922de29..ccd790a96 100644 --- a/sherpa-onnx/csrc/piper-phonemize-lexicon.h +++ b/sherpa-onnx/csrc/piper-phonemize-lexicon.h @@ -9,11 +9,6 @@ #include #include -#if __ANDROID_API__ >= 9 -#include "android/asset_manager.h" -#include "android/asset_manager_jni.h" -#endif - #include "sherpa-onnx/csrc/offline-tts-frontend.h" #include "sherpa-onnx/csrc/offline-tts-vits-model-metadata.h" @@ -24,11 +19,10 @@ class PiperPhonemizeLexicon : public OfflineTtsFrontend { PiperPhonemizeLexicon(const std::string &tokens, const std::string &data_dir, const OfflineTtsVitsModelMetaData &meta_data); -#if __ANDROID_API__ >= 9 - PiperPhonemizeLexicon(AAssetManager *mgr, const std::string &tokens, + template + PiperPhonemizeLexicon(Manager *mgr, const std::string &tokens, const std::string &data_dir, const OfflineTtsVitsModelMetaData &meta_data); -#endif std::vector ConvertTextToTokenIds( const std::string &text, const std::string &voice = "") const override;