Skip to content

Commit 55159e0

Browse files
authored
Treat <unk> as blank (#315)
1 parent 41ebcfb commit 55159e0

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

sherpa-ncnn/csrc/greedy-search-decoder.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ void GreedySearchDecoder::Decode(ncnn::Mat encoder_out, DecoderResult *result) {
7171
std::max_element(joiner_out_ptr, joiner_out_ptr + joiner_out.w)));
7272

7373
// the blank ID is fixed to 0
74-
if (new_token != 0) {
74+
if (new_token != 0 && new_token != 2) {
7575
result->tokens.push_back(new_token);
7676
ncnn::Mat decoder_input = BuildDecoderInput(*result);
7777
decoder_out = model_->RunDecoder(decoder_input);

sherpa-ncnn/csrc/modified-beam-search-decoder.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ void ModifiedBeamSearchDecoder::Decode(ncnn::Mat encoder_out,
169169
Hypothesis new_hyp = prev[hyp_index];
170170

171171
// blank id is fixed to 0
172-
if (new_token != 0) {
172+
if (new_token != 0 && new_token != 2) {
173173
new_hyp.ys.push_back(new_token);
174174
new_hyp.num_trailing_blanks = 0;
175175
new_hyp.timestamps.push_back(t + frame_offset);
@@ -247,7 +247,7 @@ void ModifiedBeamSearchDecoder::Decode(ncnn::Mat encoder_out, Stream *s,
247247
float context_score = 0;
248248
auto context_state = new_hyp.context_state;
249249
// blank id is fixed to 0
250-
if (new_token != 0) {
250+
if (new_token != 0 && new_token != 2) {
251251
new_hyp.ys.push_back(new_token);
252252
new_hyp.num_trailing_blanks = 0;
253253
new_hyp.timestamps.push_back(t + frame_offset);

0 commit comments

Comments
 (0)