Skip to content

Commit

Permalink
Merge remote-tracking branch 'dan/master' into onnxruntime-1.17.1
Browse files Browse the repository at this point in the history
  • Loading branch information
csukuangfj committed Mar 1, 2024
2 parents 769429b + d569643 commit 3877784
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 4 deletions.
6 changes: 4 additions & 2 deletions sherpa-onnx/csrc/offline-tts-vits-impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,8 @@ class OfflineTtsVitsImpl : public OfflineTtsImpl {
if (meta_data.frontend == "characters") {
frontend_ = std::make_unique<OfflineTtsCharacterFrontend>(
mgr, config_.model.vits.tokens, meta_data);
} else if ((meta_data.is_piper || meta_data.is_coqui) &&
} else if ((meta_data.is_piper || meta_data.is_coqui ||
meta_data.is_icefall) &&
!config_.model.vits.data_dir.empty()) {
frontend_ = std::make_unique<PiperPhonemizeLexicon>(
mgr, config_.model.vits.tokens, config_.model.vits.data_dir,
Expand All @@ -231,7 +232,8 @@ class OfflineTtsVitsImpl : public OfflineTtsImpl {
if (meta_data.frontend == "characters") {
frontend_ = std::make_unique<OfflineTtsCharacterFrontend>(
config_.model.vits.tokens, meta_data);
} else if ((meta_data.is_piper || meta_data.is_coqui) &&
} else if ((meta_data.is_piper || meta_data.is_coqui ||
meta_data.is_icefall) &&
!config_.model.vits.data_dir.empty()) {
frontend_ = std::make_unique<PiperPhonemizeLexicon>(
config_.model.vits.tokens, config_.model.vits.data_dir,
Expand Down
1 change: 1 addition & 0 deletions sherpa-onnx/csrc/offline-tts-vits-model-metadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ struct OfflineTtsVitsModelMetaData {

bool is_piper = false;
bool is_coqui = false;
bool is_icefall = false;

// the following options are for models from coqui-ai/TTS
int32_t blank_id = 0;
Expand Down
4 changes: 4 additions & 0 deletions sherpa-onnx/csrc/offline-tts-vits-model.cc
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ class OfflineTtsVitsModel::Impl {
if (comment.find("coqui") != std::string::npos) {
meta_data_.is_coqui = true;
}

if (comment.find("icefall") != std::string::npos) {
meta_data_.is_icefall = true;
}
}

Ort::Value RunVitsPiperOrCoqui(Ort::Value x, int64_t sid, float speed) {
Expand Down
2 changes: 1 addition & 1 deletion sherpa-onnx/csrc/piper-phonemize-lexicon.cc
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ std::vector<std::vector<int64_t>> PiperPhonemizeLexicon::ConvertTextToTokenIds(

std::vector<int64_t> phoneme_ids;

if (meta_data_.is_piper) {
if (meta_data_.is_piper || meta_data_.is_icefall) {
for (const auto &p : phonemes) {
phoneme_ids = PiperPhonemesToIds(token2id_, p);
ans.push_back(std::move(phoneme_ids));
Expand Down
4 changes: 3 additions & 1 deletion sherpa-onnx/csrc/session.cc
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,13 @@ static Ort::SessionOptions GetSessionOptionsImpl(int32_t num_threads,
} else {
SHERPA_ONNX_LOGE("Use nnapi");
}
#else
#elif defined(__ANDROID_API__)
SHERPA_ONNX_LOGE(
"Android NNAPI requires API level >= 27. Current API level %d "
"Fallback to cpu!",
(int32_t)__ANDROID_API__);
#else
SHERPA_ONNX_LOGE("NNAPI is for Android only. Fallback to cpu");
#endif
break;
}
Expand Down

0 comments on commit 3877784

Please sign in to comment.