From b1d1f89f586120a978a4666cffd45c55f0a2e564 Mon Sep 17 00:00:00 2001 From: Tatiana Likhomanenko Date: Fri, 16 Oct 2020 13:48:57 -0700 Subject: [PATCH] with @qiantong fix lexicon decoder for --surround usage with CTC criterion --- Decode.cpp | 2 +- src/libraries/decoder/LexiconDecoder.cpp | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Decode.cpp b/Decode.cpp index e68605a7..cb41e407 100644 --- a/Decode.cpp +++ b/Decode.cpp @@ -251,7 +251,7 @@ int main(int argc, char** argv) { FLAGS_criterion == kCtcCriterion ? tokenDict.getIndex(kBlankToken) : -1; int silIdx = -1; if (FLAGS_wordseparator != "") { - tokenDict.getIndex(FLAGS_wordseparator); + silIdx = tokenDict.getIndex(FLAGS_wordseparator); } std::shared_ptr trie = nullptr; if (FLAGS_decodertype == "wrd" || FLAGS_uselexicon) { diff --git a/src/libraries/decoder/LexiconDecoder.cpp b/src/libraries/decoder/LexiconDecoder.cpp index 66c4cbf9..00806724 100644 --- a/src/libraries/decoder/LexiconDecoder.cpp +++ b/src/libraries/decoder/LexiconDecoder.cpp @@ -154,8 +154,9 @@ void LexiconDecoder::decodeStep(const float* emissions, int T, int N) { } /* (2) Try same lexicon node */ - if (opt_.criterionType != CriterionType::CTC || !prevHyp.prevBlank) { - int n = prevIdx; + if (opt_.criterionType != CriterionType::CTC || !prevHyp.prevBlank || + prevLex == lexicon_->getRoot()) { + int n = prevLex == lexicon_->getRoot() ? sil_ : prevIdx; double amScore = emissions[t * N + n]; if (nDecodedFrames_ + t > 0 && opt_.criterionType == CriterionType::ASG) {