aboutsummaryrefslogtreecommitdiff
path: root/swr2_asr
diff options
context:
space:
mode:
Diffstat (limited to 'swr2_asr')
-rw-r--r--swr2_asr/train.py6
-rw-r--r--swr2_asr/utils/decoder.py3
2 files changed, 6 insertions, 3 deletions
diff --git a/swr2_asr/train.py b/swr2_asr/train.py
index 1e57ba0..5277c16 100644
--- a/swr2_asr/train.py
+++ b/swr2_asr/train.py
@@ -142,8 +142,10 @@ def test(test_args: TestArgs) -> tuple[float, float, float]:
for j, _ in enumerate(decoded_preds):
if j >= len(decoded_targets):
break
- test_cer.append(cer(decoded_targets[j], decoded_preds[j][0].words[0]))
- test_wer.append(wer(decoded_targets[j], decoded_preds[j][0].words[0]))
+ pred = " ".join(decoded_preds[j][0].words).strip() # batch, top, words
+ target = decoded_targets[j]
+ test_cer.append(cer(target, pred))
+ test_wer.append(wer(target, pred))
avg_cer = sum(test_cer) / len(test_cer)
avg_wer = sum(test_wer) / len(test_wer)
diff --git a/swr2_asr/utils/decoder.py b/swr2_asr/utils/decoder.py
index 6ffdef2..1fd002a 100644
--- a/swr2_asr/utils/decoder.py
+++ b/swr2_asr/utils/decoder.py
@@ -98,7 +98,8 @@ class GreedyDecoder:
if greedy_type == "inference":
res = self.inference(output)
- res = [[DecoderOutput(words=res)]]
+ res = [x.split(" ") for x in res]
+ res = [[DecoderOutput(x)] for x in res]
return res
def train(self, output, labels, label_lengths):