From c02c65026ed37c0adef28e83a4f81100dc41332b Mon Sep 17 00:00:00 2001 From: Yibing Liu Date: Sun, 18 Jun 2017 18:11:01 +0800 Subject: [PATCH] add scoring last word in beam search --- deep_speech_2/decoder.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/deep_speech_2/decoder.py b/deep_speech_2/decoder.py index 2ee89cbd..37640aff 100755 --- a/deep_speech_2/decoder.py +++ b/deep_speech_2/decoder.py @@ -222,8 +222,11 @@ def ctc_beam_search_decoder(probs_seq, beam_result = [] for (seq, prob) in prefix_set_prev.items(): - if prob > 0.0: + if prob > 0.0 and len(seq) > 1: result = seq[1:] + # score last word by external scorer + if (ext_scoring_func is not None) and (result[-1] != ' '): + prob = prob * ext_scoring_func(result) log_prob = np.log(prob) beam_result.append([log_prob, result]) -- GitLab