diff --git a/runtime/core/decoder/ctc_endpoint.cc b/runtime/core/decoder/ctc_endpoint.cc index 7b7c6823c2..0ea032aec1 100644 --- a/runtime/core/decoder/ctc_endpoint.cc +++ b/runtime/core/decoder/ctc_endpoint.cc @@ -54,7 +54,7 @@ bool CtcEndpoint::IsEndpoint( float blank_prob = expf(logp_t[config_.blank]); num_frames_decoded_++; - if (blank_prob > config_.blank_threshold) { + if (blank_prob > config_.blank_threshold * config_.blank_scale) { num_frames_trailing_blank_++; } else { num_frames_trailing_blank_ = 0; diff --git a/runtime/core/decoder/ctc_endpoint.h b/runtime/core/decoder/ctc_endpoint.h index 09a97a1dd3..bfeab639ae 100644 --- a/runtime/core/decoder/ctc_endpoint.h +++ b/runtime/core/decoder/ctc_endpoint.h @@ -34,6 +34,7 @@ struct CtcEndpointRule { struct CtcEndpointConfig { /// We consider blank as silence for purposes of endpointing. int blank = 0; // blank id + float blank_scale = 1.0; // blank scale float blank_threshold = 0.8; // blank threshold to be silence /// We support three rules. We terminate decoding if ANY of these rules /// evaluates to "true". If you want to add more rules, do it by changing this diff --git a/runtime/core/decoder/params.h b/runtime/core/decoder/params.h index c3672c8ebd..06ba79669a 100644 --- a/runtime/core/decoder/params.h +++ b/runtime/core/decoder/params.h @@ -157,6 +157,7 @@ std::shared_ptr InitDecodeOptionsFromFlags() { decode_config->ctc_prefix_search_opts.second_beam_size = FLAGS_nbest; decode_config->ctc_prefix_search_opts.blank = FLAGS_blank_id; decode_config->ctc_endpoint_config.blank = FLAGS_blank_id; + decode_config->ctc_endpoint_config.blank_scale = FLAGS_blank_scale; return decode_config; }