diff --git a/android/SherpaOnnxTts/app/src/main/java/com/k2fsa/sherpa/onnx/MainActivity.kt b/android/SherpaOnnxTts/app/src/main/java/com/k2fsa/sherpa/onnx/MainActivity.kt index 88f7e2202..5a5b4e077 100644 --- a/android/SherpaOnnxTts/app/src/main/java/com/k2fsa/sherpa/onnx/MainActivity.kt +++ b/android/SherpaOnnxTts/app/src/main/java/com/k2fsa/sherpa/onnx/MainActivity.kt @@ -77,20 +77,13 @@ class MainActivity : AppCompatActivity() { return } - Toast.makeText(applicationContext, "Generating...Please wait", Toast.LENGTH_LONG).show() + play.isEnabled = false; val audio = tts.generate(text = textStr, sid = sidInt, speed = speedFloat) val filename = application.filesDir.absolutePath + "/generated.wav" val ok = audio.samples.size > 0 && audio.save(filename) if (ok) { play.isEnabled = true - Toast.makeText( - applicationContext, - "Generated! Please click play to listen to it", - Toast.LENGTH_LONG - ).show() - } else { - play.isEnabled = false } } @@ -110,4 +103,4 @@ class MainActivity : AppCompatActivity() { val config = getOfflineTtsConfig(type = type, debug = true)!! tts = OfflineTts(assetManager = application.assets, config = config) } -} \ No newline at end of file +} diff --git a/sherpa-onnx/csrc/lexicon.cc b/sherpa-onnx/csrc/lexicon.cc index c036a7a36..88f95f1f6 100644 --- a/sherpa-onnx/csrc/lexicon.cc +++ b/sherpa-onnx/csrc/lexicon.cc @@ -129,10 +129,12 @@ std::vector Lexicon::ConvertTextToTokenIds( switch (language_) { case Language::kEnglish: return ConvertTextToTokenIdsEnglish(text); + case Language::kGerman: + return ConvertTextToTokenIdsGerman(text); case Language::kChinese: return ConvertTextToTokenIdsChinese(text); default: - SHERPA_ONNX_LOGE("Unknonw language: %d", static_cast(language_)); + SHERPA_ONNX_LOGE("Unknown language: %d", static_cast(language_)); exit(-1); } @@ -246,6 +248,8 @@ void Lexicon::InitLanguage(const std::string &_lang) { ToLowerCase(&lang); if (lang == "english") { language_ = Language::kEnglish; + } else if (lang == "german") { + language_ = Language::kGerman; } else if (lang == "chinese") { language_ = Language::kChinese; } else { @@ -269,8 +273,8 @@ void Lexicon::InitLexicon(std::istream &is) { ToLowerCase(&word); if (word2ids_.count(word)) { - SHERPA_ONNX_LOGE("Duplicated word: %s", word.c_str()); - return; + SHERPA_ONNX_LOGE("Duplicated word: %s. Ignore it.", word.c_str()); + continue; } while (iss >> phone) { diff --git a/sherpa-onnx/csrc/lexicon.h b/sherpa-onnx/csrc/lexicon.h index dfc6cf9fd..fcf791422 100644 --- a/sherpa-onnx/csrc/lexicon.h +++ b/sherpa-onnx/csrc/lexicon.h @@ -36,6 +36,11 @@ class Lexicon { std::vector ConvertTextToTokenIds(const std::string &text) const; private: + std::vector ConvertTextToTokenIdsGerman( + const std::string &text) const { + return ConvertTextToTokenIdsEnglish(text); + } + std::vector ConvertTextToTokenIdsEnglish( const std::string &text) const; @@ -50,6 +55,7 @@ class Lexicon { private: enum class Language { kEnglish, + kGerman, kChinese, kUnknown, };