Skip to content

Commit e96ffe0

Browse files
authored
Modify TreeTimesyncBeamSearch: don't force LM to ignore blank and silence (#145)
1 parent a870022 commit e96ffe0

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

src/Search/TreeTimesyncBeamSearch/TreeTimesyncBeamSearch.cc

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,12 @@ bool TreeTimesyncBeamSearch::setModelCombination(Speech::ModelCombination const&
212212
useBlank_ = false;
213213
}
214214

215+
for (const auto& lemma : {"silence", "blank"}) {
216+
if (lexicon_->specialLemma(lemma) and (lexicon_->specialLemma(lemma)->syntacticTokenSequence()).size() != 0) {
217+
warning("Special lemma \"%s\" will be scored by the language model. To prevent the LM from scoring it, set an empty syntactic token sequence for it in the lexicon.", lemma);
218+
}
219+
}
220+
215221
// Create look-ups for state successors and exits of each state
216222
createSuccessorLookups();
217223

@@ -421,9 +427,10 @@ bool TreeTimesyncBeamSearch::decodeStep() {
421427
Nn::LabelScorer::TransitionType::INITIAL_BLANK, // The transition type is irrelevant, so just use this as dummy
422428
hypIndex};
423429

424-
if (lemma != lexicon_->specialLemma("blank") and lemma != lexicon_->specialLemma("silence")) {
425-
const Bliss::SyntacticTokenSequence sts = lemma->syntacticTokenSequence();
426-
const Bliss::SyntacticToken* st = sts.front();
430+
const Bliss::SyntacticTokenSequence sts = lemma->syntacticTokenSequence();
431+
if (sts.size() != 0) {
432+
require(sts.size() == 1);
433+
const Bliss::SyntacticToken* st = sts.front();
427434

428435
// Add the LM score
429436
Lm::Score lmScore = languageModel_->score(wordEndExtension.lmHistory, st);
@@ -447,11 +454,12 @@ bool TreeTimesyncBeamSearch::decodeStep() {
447454
// Create new word-end label hypotheses from word-end extension candidates and update the LM history
448455
wordEndHypotheses_.clear();
449456
for (auto& extension : extensions_) {
450-
const Bliss::Lemma* lemma = extension.pron->lemma();
451-
if (lemma != lexicon_->specialLemma("blank") and lemma != lexicon_->specialLemma("silence")) {
452-
const Bliss::SyntacticTokenSequence sts = lemma->syntacticTokenSequence();
453-
const Bliss::SyntacticToken* st = sts.front();
454-
extension.lmHistory = languageModel_->extendedHistory(extension.lmHistory, st);
457+
const Bliss::Lemma* lemma = extension.pron->lemma();
458+
const Bliss::SyntacticTokenSequence sts = lemma->syntacticTokenSequence();
459+
if (sts.size() != 0) {
460+
require(sts.size() == 1);
461+
const Bliss::SyntacticToken* st = sts.front();
462+
extension.lmHistory = languageModel_->extendedHistory(extension.lmHistory, st);
455463
}
456464

457465
auto const& baseHyp = newBeam_[extension.baseHypIndex];

0 commit comments

Comments
 (0)