Committed by
GitHub
Show verbose logs in homophone replacer (#2194)
正在显示
2 个修改的文件
包含
11 行增加
和
2 行删除
| @@ -90,7 +90,7 @@ jobs: | @@ -90,7 +90,7 @@ jobs: | ||
| 90 | run: | | 90 | run: | |
| 91 | opts='--break-system-packages' | 91 | opts='--break-system-packages' |
| 92 | v=${{ matrix.python-version }} | 92 | v=${{ matrix.python-version }} |
| 93 | - if [[ $v == cp37 || $v == cp38 || $v == cp39 ]]; then | 93 | + if [[ $v == cp38 || $v == cp39 ]]; then |
| 94 | opts='' | 94 | opts='' |
| 95 | fi | 95 | fi |
| 96 | 96 |
| @@ -143,6 +143,12 @@ class HomophoneReplacer::Impl { | @@ -143,6 +143,12 @@ class HomophoneReplacer::Impl { | ||
| 143 | } | 143 | } |
| 144 | 144 | ||
| 145 | std::string Apply(const std::string &text) const { | 145 | std::string Apply(const std::string &text) const { |
| 146 | + std::string ans; | ||
| 147 | + | ||
| 148 | + if (text.empty()) { | ||
| 149 | + return ans; | ||
| 150 | + } | ||
| 151 | + | ||
| 146 | bool is_hmm = true; | 152 | bool is_hmm = true; |
| 147 | 153 | ||
| 148 | std::vector<std::string> words; | 154 | std::vector<std::string> words; |
| @@ -170,13 +176,16 @@ class HomophoneReplacer::Impl { | @@ -170,13 +176,16 @@ class HomophoneReplacer::Impl { | ||
| 170 | pronunciations.push_back(std::move(p)); | 176 | pronunciations.push_back(std::move(p)); |
| 171 | } | 177 | } |
| 172 | 178 | ||
| 173 | - std::string ans; | ||
| 174 | for (const auto &r : replacer_list_) { | 179 | for (const auto &r : replacer_list_) { |
| 175 | ans = r->Normalize(words, pronunciations); | 180 | ans = r->Normalize(words, pronunciations); |
| 176 | // TODO(fangjun): We support only 1 rule fst at present. | 181 | // TODO(fangjun): We support only 1 rule fst at present. |
| 177 | break; | 182 | break; |
| 178 | } | 183 | } |
| 179 | 184 | ||
| 185 | + if (config_.debug) { | ||
| 186 | + SHERPA_ONNX_LOGE("Output text: '%s'", ans.c_str()); | ||
| 187 | + } | ||
| 188 | + | ||
| 180 | return ans; | 189 | return ans; |
| 181 | } | 190 | } |
| 182 | 191 |
-
请 注册 或 登录 后发表评论