Show verbose logs in homophone replacer (#2194)

This commit is contained in:
Fangjun Kuang
2025-05-09 10:48:30 +08:00
committed by GitHub
parent 562a5f7d9b
commit a6834f6556
2 changed files with 11 additions and 2 deletions

View File

@@ -90,7 +90,7 @@ jobs:
run: |
opts='--break-system-packages'
v=${{ matrix.python-version }}
if [[ $v == cp37 || $v == cp38 || $v == cp39 ]]; then
if [[ $v == cp38 || $v == cp39 ]]; then
opts=''
fi

View File

@@ -143,6 +143,12 @@ class HomophoneReplacer::Impl {
}
std::string Apply(const std::string &text) const {
std::string ans;
if (text.empty()) {
return ans;
}
bool is_hmm = true;
std::vector<std::string> words;
@@ -170,13 +176,16 @@ class HomophoneReplacer::Impl {
pronunciations.push_back(std::move(p));
}
std::string ans;
for (const auto &r : replacer_list_) {
ans = r->Normalize(words, pronunciations);
// TODO(fangjun): We support only 1 rule fst at present.
break;
}
if (config_.debug) {
SHERPA_ONNX_LOGE("Output text: '%s'", ans.c_str());
}
return ans;
}