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>
正在显示
1 个修改的文件
包含
7 行增加
和
7 行删除
| @@ -382,13 +382,6 @@ class OnlineRecognizerTransducerImpl : public OnlineRecognizerImpl { | @@ -382,13 +382,6 @@ class OnlineRecognizerTransducerImpl : public OnlineRecognizerImpl { | ||
| 382 | // s->SetStates(model_->GetEncoderInitStates()); | 382 | // s->SetStates(model_->GetEncoderInitStates()); |
| 383 | 383 | ||
| 384 | auto r = decoder_->GetEmptyResult(); | 384 | auto r = decoder_->GetEmptyResult(); |
| 385 | - if (config_.decoding_method == "modified_beam_search" && | ||
| 386 | - nullptr != s->GetContextGraph()) { | ||
| 387 | - for (auto it = r.hyps.begin(); it != r.hyps.end(); ++it) { | ||
| 388 | - it->second.context_state = s->GetContextGraph()->Root(); | ||
| 389 | - } | ||
| 390 | - } | ||
| 391 | - | ||
| 392 | auto last_result = s->GetResult(); | 385 | auto last_result = s->GetResult(); |
| 393 | // if last result is not empty, then | 386 | // if last result is not empty, then |
| 394 | // preserve last tokens as the context for next result | 387 | // preserve last tokens as the context for next result |
| @@ -401,6 +394,13 @@ class OnlineRecognizerTransducerImpl : public OnlineRecognizerImpl { | @@ -401,6 +394,13 @@ class OnlineRecognizerTransducerImpl : public OnlineRecognizerImpl { | ||
| 401 | r.tokens = std::move(context); | 394 | r.tokens = std::move(context); |
| 402 | } | 395 | } |
| 403 | 396 | ||
| 397 | + if (config_.decoding_method == "modified_beam_search" && | ||
| 398 | + nullptr != s->GetContextGraph()) { | ||
| 399 | + for (auto it = r.hyps.begin(); it != r.hyps.end(); ++it) { | ||
| 400 | + it->second.context_state = s->GetContextGraph()->Root(); | ||
| 401 | + } | ||
| 402 | + } | ||
| 403 | + | ||
| 404 | s->SetResult(r); | 404 | s->SetResult(r); |
| 405 | 405 | ||
| 406 | // Note: We only update counters. The underlying audio samples | 406 | // Note: We only update counters. The underlying audio samples |
-
请 注册 或 登录 后发表评论