From e20595753fd3843c1e921dd0cb56246b287ab7b3 Mon Sep 17 00:00:00 2001 From: dujing Date: Mon, 18 Sep 2023 15:23:51 +0800 Subject: [PATCH] [ctc]fix false rejection result from long time silence. --- wekws/bin/stream_kws_ctc.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/wekws/bin/stream_kws_ctc.py b/wekws/bin/stream_kws_ctc.py index 07e01e4..fbc6584 100644 --- a/wekws/bin/stream_kws_ctc.py +++ b/wekws/bin/stream_kws_ctc.py @@ -481,6 +481,15 @@ class KeyWordSpotter(torch.nn.Module): # update frame offset self.total_frames += len(probs) * self.downsampling + + # For streaming kws, the cur_hyps should be reset if the time of + # a possible keyword last over the max_frames value you set. + # see this issue:https://github.com/duj12/kws_demo/issues/2 + if len(self.cur_hyps[0][0]) > 0: + keyword_may_start = int(self.cur_hyps[0][1][2][0]['frame']) + if (self.total_frames - keyword_may_start) > self.max_frames: + self.reset() + return self.result def reset(self):