aboutsummaryrefslogtreecommitdiff
path: root/swr2_asr/utils
diff options
context:
space:
mode:
authorJoJoBarthold22023-09-16 15:23:56 +0200
committerJoJoBarthold22023-09-16 15:23:56 +0200
commit80544737bc4338bd0cde305b8bccb7c5209e1bdc (patch)
treed1ecd9681453b8ca75d281605778cb75462c0e2d /swr2_asr/utils
parentc46fecf9cf1110d286259ae2bc81eff3ed21cc23 (diff)
added a method to create a txt for the ctc decoder
Diffstat (limited to 'swr2_asr/utils')
-rw-r--r--swr2_asr/utils/decoder.py1
-rw-r--r--swr2_asr/utils/tokenizer.py6
2 files changed, 7 insertions, 0 deletions
diff --git a/swr2_asr/utils/decoder.py b/swr2_asr/utils/decoder.py
index fcddb79..ef8de49 100644
--- a/swr2_asr/utils/decoder.py
+++ b/swr2_asr/utils/decoder.py
@@ -24,3 +24,4 @@ def greedy_decoder(output, labels, label_lengths, tokenizer: CharTokenizer, coll
# TODO: add beam search decoder
+
diff --git a/swr2_asr/utils/tokenizer.py b/swr2_asr/utils/tokenizer.py
index 1cc7b84..ee89cdb 100644
--- a/swr2_asr/utils/tokenizer.py
+++ b/swr2_asr/utils/tokenizer.py
@@ -120,3 +120,9 @@ class CharTokenizer:
load_tokenizer.char_map[char] = int(index)
load_tokenizer.index_map[int(index)] = char
return load_tokenizer
+
+ def create_txt(self,path:str):
+ with open(path, 'w',encoding="utf-8") as file:
+ for key,value in self.char_map():
+ file.write(f"{key}\n")
+ \ No newline at end of file