Skip to content

Commit 59046b8

Browse files
author
Olivier Birot
committed
In filter_ctc_output(), remove redundant code
Before this commit we were filtering out twice the repeated tokens: once with the list comprehension and once with groupby.
1 parent 51f60fc commit 59046b8

1 file changed

Lines changed: 1 addition & 8 deletions

File tree

speechbrain/decoders/ctc.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -322,14 +322,7 @@ def filter_ctc_output(string_pred, blank_id=-1):
322322

323323
if isinstance(string_pred, list):
324324
# Filter the repetitions
325-
string_out = [
326-
v
327-
for i, v in enumerate(string_pred)
328-
if i == 0 or v != string_pred[i - 1]
329-
]
330-
331-
# Remove duplicates
332-
string_out = [i[0] for i in groupby(string_out)]
325+
string_out = [i[0] for i in groupby(string_pred)]
333326

334327
# Filter the blank symbol
335328
string_out = list(filter(lambda elem: elem != blank_id, string_out))

0 commit comments

Comments
 (0)