Skip to content
This repository was archived by the owner on Aug 3, 2021. It is now read-only.

Commit 61204b2

Browse files
authored
Merge pull request #517 from jarivk/dev/separate_reset_flags
Provide separate flags to reset offsets and words
2 parents a81babd + 5ccc608 commit 61204b2

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

decoders/ctc_beam_search_decoder.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ BeamDecoder::~BeamDecoder()
259259
}
260260

261261

262-
void BeamDecoder::reset(bool partial /* default = false */)
262+
void BeamDecoder::reset(bool keep_offset /*default = false*/, bool keep_words /*default = false*/)
263263
{
264264
// init prefixes' root
265265
if (root != nullptr) {
@@ -279,15 +279,20 @@ void BeamDecoder::reset(bool partial /* default = false */)
279279
root->set_matcher(matcher);
280280
}
281281

282-
if (partial) {
282+
if (keep_offset) {
283+
prev_time_offset += last_decoded_timestep + time_offset;
284+
} else {
285+
prev_time_offset = 0;
286+
}
287+
288+
if (keep_words) {
283289
prev_wordlist.insert(
284290
std::end(prev_wordlist), std::begin(wordlist),
285291
std::end(wordlist));
286-
prev_time_offset += last_decoded_timestep + time_offset;
287292
} else {
288293
prev_wordlist.clear();
289-
prev_time_offset = 0;
290294
}
295+
291296
wordlist.clear();
292297
time_offset = 0;
293298
last_decoded_timestep = 0;

decoders/ctc_beam_search_decoder.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class BeamDecoder {
5151
void set_start_offset(int offset) { time_offset = offset; }
5252

5353
// reset state
54-
void reset(bool partial = false);
54+
void reset(bool keep_offset = false, bool keep_words = false);
5555

5656
private:
5757
Scorer *ext_scorer;

0 commit comments

Comments
 (0)