Skip to content

Commit

Permalink
context_state is not set correctly when previous context is passed af…
Browse files Browse the repository at this point in the history
…ter reset (#1393)

Co-authored-by: vsd-vector <[email protected]>
  • Loading branch information
vsd-vector and vsd-vector authored Oct 3, 2024
1 parent 66feecb commit 5f50cbf
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions sherpa-onnx/csrc/online-recognizer-transducer-impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 5f50cbf

Please sign in to comment.