Show verbose logs in homophone replacer (#2194)
This commit is contained in:
@@ -90,7 +90,7 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
opts='--break-system-packages'
|
opts='--break-system-packages'
|
||||||
v=${{ matrix.python-version }}
|
v=${{ matrix.python-version }}
|
||||||
if [[ $v == cp37 || $v == cp38 || $v == cp39 ]]; then
|
if [[ $v == cp38 || $v == cp39 ]]; then
|
||||||
opts=''
|
opts=''
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
@@ -143,6 +143,12 @@ class HomophoneReplacer::Impl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string Apply(const std::string &text) const {
|
std::string Apply(const std::string &text) const {
|
||||||
|
std::string ans;
|
||||||
|
|
||||||
|
if (text.empty()) {
|
||||||
|
return ans;
|
||||||
|
}
|
||||||
|
|
||||||
bool is_hmm = true;
|
bool is_hmm = true;
|
||||||
|
|
||||||
std::vector<std::string> words;
|
std::vector<std::string> words;
|
||||||
@@ -170,13 +176,16 @@ class HomophoneReplacer::Impl {
|
|||||||
pronunciations.push_back(std::move(p));
|
pronunciations.push_back(std::move(p));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string ans;
|
|
||||||
for (const auto &r : replacer_list_) {
|
for (const auto &r : replacer_list_) {
|
||||||
ans = r->Normalize(words, pronunciations);
|
ans = r->Normalize(words, pronunciations);
|
||||||
// TODO(fangjun): We support only 1 rule fst at present.
|
// TODO(fangjun): We support only 1 rule fst at present.
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (config_.debug) {
|
||||||
|
SHERPA_ONNX_LOGE("Output text: '%s'", ans.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
return ans;
|
return ans;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user