Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions src/Search/TreeTimesyncBeamSearch/TreeTimesyncBeamSearch.cc
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,16 @@ const Core::ParameterBool TreeTimesyncBeamSearch::paramCollapseRepeatedLabels(
"Collapse repeated emission of the same label into one output. If false, every emission is treated like a new output.",
false);

const Core::ParameterFloat TreeTimesyncBeamSearch::paramWordExitPenalty(
"word-exit-penalty",
"Constant score which is added at a word end.",
0);

const Core::ParameterFloat TreeTimesyncBeamSearch::paramSilencePenalty(
"silence-penalty",
"Constant score which is added when predicting silence. If not set, it will be the same as word-exit-penalty.",
Core::Type<Score>::min);

const Core::ParameterBool TreeTimesyncBeamSearch::paramSentenceEndFallBack(
"sentence-end-fall-back",
"Allow for fallback solution if no active word-end hypothesis exists at the end of a segment.",
Expand All @@ -139,6 +149,8 @@ TreeTimesyncBeamSearch::TreeTimesyncBeamSearch(Core::Configuration const& config
maxWordEndBeamSize_(paramMaxWordEndBeamSize(config)),
scoreThreshold_(paramScoreThreshold(config)),
wordEndScoreThreshold_(paramWordEndScoreThreshold(config)),
wordExitPenalty_(paramWordExitPenalty(config)),
silencePenalty_(paramSilencePenalty(config)),
cacheCleanupInterval_(paramCacheCleanupInterval(config)),
useBlank_(),
collapseRepeatedLabels_(paramCollapseRepeatedLabels(config)),
Expand Down Expand Up @@ -171,6 +183,10 @@ TreeTimesyncBeamSearch::TreeTimesyncBeamSearch(Core::Configuration const& config
error() << "Word-end score-threshold which is relative to the score-threshold is set, but score-threshold is not set";
}
wordEndScoreThreshold_ *= scoreThreshold_;

if (silencePenalty_ == Core::Type<Score>::min) {
silencePenalty_ = wordExitPenalty_;
}
}

Speech::ModelCombination::Mode TreeTimesyncBeamSearch::requiredModelCombination() const {
Expand Down Expand Up @@ -463,7 +479,19 @@ bool TreeTimesyncBeamSearch::decodeStep() {
Lm::Score lmScore = languageModel_->score(wordEndExtension.lmHistory, st);
wordEndExtension.score += lmScore;
wordEndExtension.lmScore = lmScore;

// Add exit penalty for silence or for non-silence word
if (lemma == lexicon_->specialLemma("silence")) {
wordEndExtension.score += silencePenalty_;
}
else {
wordEndExtension.score += wordExitPenalty_;
}
}
else if (lemma == lexicon_->specialLemma("silence")) {
wordEndExtension.score += silencePenalty_;
}

extensions_.push_back(wordEndExtension);
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/Search/TreeTimesyncBeamSearch/TreeTimesyncBeamSearch.hh
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ public:
static const Core::ParameterFloat paramScoreThreshold;
static const Core::ParameterFloat paramWordEndScoreThreshold;
static const Core::ParameterBool paramCollapseRepeatedLabels;
static const Core::ParameterFloat paramWordExitPenalty;
static const Core::ParameterFloat paramSilencePenalty;
static const Core::ParameterBool paramSentenceEndFallBack;
static const Core::ParameterBool paramLogStepwiseStatistics;
static const Core::ParameterBool paramCacheCleanupInterval;
Expand Down Expand Up @@ -122,6 +124,8 @@ private:
size_t maxWordEndBeamSize_;
Score scoreThreshold_;
Score wordEndScoreThreshold_;
Score wordExitPenalty_;
Score silencePenalty_;
Nn::LabelIndex blankLabelIndex_;
size_t cacheCleanupInterval_;

Expand Down