Skip to content

Commit

Permalink
[ctc]fix false rejection result from long time silence. (#149)
Browse files Browse the repository at this point in the history
* [ctc]fix false rejection result from long time silence.

* fix list index out of range.

---------

Co-authored-by: dujing <[email protected]>
  • Loading branch information
duj12 and dujing authored Oct 9, 2023
1 parent 58859d5 commit 059fd87
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions wekws/bin/stream_kws_ctc.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,15 @@ def forward(self, wave_chunk):

# 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 and 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):
Expand Down

0 comments on commit 059fd87

Please sign in to comment.