Askars
Committed by GitHub

context_state is not set correctly when previous context is passed after reset (#1393)

Co-authored-by: vsd-vector <askars.salimbajevs@tilde.lv>
... ... @@ -382,13 +382,6 @@ class OnlineRecognizerTransducerImpl : public OnlineRecognizerImpl {
// s->SetStates(model_->GetEncoderInitStates());
auto r = decoder_->GetEmptyResult();
if (config_.decoding_method == "modified_beam_search" &&
nullptr != s->GetContextGraph()) {
for (auto it = r.hyps.begin(); it != r.hyps.end(); ++it) {
it->second.context_state = s->GetContextGraph()->Root();
}
}
auto last_result = s->GetResult();
// if last result is not empty, then
// preserve last tokens as the context for next result
... ... @@ -401,6 +394,13 @@ class OnlineRecognizerTransducerImpl : public OnlineRecognizerImpl {
r.tokens = std::move(context);
}
if (config_.decoding_method == "modified_beam_search" &&
nullptr != s->GetContextGraph()) {
for (auto it = r.hyps.begin(); it != r.hyps.end(); ++it) {
it->second.context_state = s->GetContextGraph()->Root();
}
}
s->SetResult(r);
// Note: We only update counters. The underlying audio samples
... ...