ahadjawaid
Committed by GitHub

Fix: made print sherpa_onnx_loge when it is in debug mode (#1838)

Currently, during normal use you may get a lot of print statements such as: `Use espeak-ng to handle the OOV: 'ipsum'` which may not be relevant unless you are debugging.
@@ -193,9 +193,11 @@ class KokoroMultiLangLexicon::Impl { @@ -193,9 +193,11 @@ class KokoroMultiLangLexicon::Impl {
193 auto ids = ConvertWordToIds(word); 193 auto ids = ConvertWordToIds(word);
194 ans.insert(ans.end(), ids.begin(), ids.end()); 194 ans.insert(ans.end(), ids.begin(), ids.end());
195 } else { 195 } else {
  196 + if (debug_) {
196 SHERPA_ONNX_LOGE("Skip OOV: '%s'", word.c_str()); 197 SHERPA_ONNX_LOGE("Skip OOV: '%s'", word.c_str());
197 } 198 }
198 } 199 }
  200 + }
199 201
200 return ans; 202 return ans;
201 } 203 }
@@ -312,7 +314,9 @@ class KokoroMultiLangLexicon::Impl { @@ -312,7 +314,9 @@ class KokoroMultiLangLexicon::Impl {
312 this_sentence.insert(this_sentence.end(), ids.begin(), ids.end()); 314 this_sentence.insert(this_sentence.end(), ids.begin(), ids.end());
313 this_sentence.push_back(space_id); 315 this_sentence.push_back(space_id);
314 } else { 316 } else {
  317 + if (debug_) {
315 SHERPA_ONNX_LOGE("Use espeak-ng to handle the OOV: '%s'", word.c_str()); 318 SHERPA_ONNX_LOGE("Use espeak-ng to handle the OOV: '%s'", word.c_str());
  319 + }
316 320
317 piper::eSpeakPhonemeConfig config; 321 piper::eSpeakPhonemeConfig config;
318 322
@@ -333,11 +337,13 @@ class KokoroMultiLangLexicon::Impl { @@ -333,11 +337,13 @@ class KokoroMultiLangLexicon::Impl {
333 if (token2id_.count(token)) { 337 if (token2id_.count(token)) {
334 ids.push_back(token2id_.at(token)); 338 ids.push_back(token2id_.at(token));
335 } else { 339 } else {
  340 + if (debug_) {
336 SHERPA_ONNX_LOGE("Skip OOV token '%s' from '%s'", token.c_str(), 341 SHERPA_ONNX_LOGE("Skip OOV token '%s' from '%s'", token.c_str(),
337 word.c_str()); 342 word.c_str());
338 } 343 }
339 } 344 }
340 } 345 }
  346 + }
341 347
342 if (this_sentence.size() + ids.size() + 3 > max_len - 2) { 348 if (this_sentence.size() + ids.size() + 3 > max_len - 2) {
343 this_sentence.push_back(0); 349 this_sentence.push_back(0);