Commit 9644c17 1 parent b9bbdfa commit 9644c17 Copy full SHA for 9644c17
File tree 3 files changed +11
-11
lines changed
librispeech/ASR/lstm_transducer_stateless2
tedlium3/ASR/conformer_ctc2
3 files changed +11
-11
lines changed Original file line number Diff line number Diff line change 28
28
2. Export the model to ONNX
29
29
30
30
./lstm_transducer_stateless2/export-onnx-zh.py \
31
- --lang-dir ./icefall-asr-wenetspeech-lstm-transducer-stateless-2022-10-14/data/lang_char \
31
+ --tokens ./icefall-asr-wenetspeech-lstm-transducer-stateless-2022-10-14/data/lang_char/tokens.txt \
32
32
--use-averaged-model 1 \
33
33
--epoch 11 \
34
34
--avg 1 \
55
55
from pathlib import Path
56
56
from typing import Dict , Optional , Tuple
57
57
58
+ import k2
58
59
import onnx
59
60
import torch
60
61
import torch .nn as nn
70
71
find_checkpoints ,
71
72
load_checkpoint ,
72
73
)
73
- from icefall .lexicon import Lexicon
74
- from icefall .utils import setup_logger , str2bool
74
+ from icefall .utils import num_tokens , setup_logger , str2bool
75
75
76
76
77
77
def get_parser ():
@@ -128,10 +128,10 @@ def get_parser():
128
128
)
129
129
130
130
parser .add_argument (
131
- "--lang-dir " ,
131
+ "--tokens " ,
132
132
type = str ,
133
- default = "data/lang_char" ,
134
- help = "The lang dir " ,
133
+ default = "data/lang_char/tokens.txt " ,
134
+ help = "Path to the tokens.txt. " ,
135
135
)
136
136
137
137
parser .add_argument (
@@ -441,9 +441,9 @@ def main():
441
441
442
442
logging .info (f"device: { device } " )
443
443
444
- lexicon = Lexicon (params .lang_dir )
445
- params .blank_id = 0
446
- params .vocab_size = max ( lexicon . tokens ) + 1
444
+ token_table = k2 . SymbolTable . from_file (params .tokens )
445
+ params .blank_id = token_table [ "<blk>" ]
446
+ params .vocab_size = num_tokens ( token_table ) + 1
447
447
448
448
logging .info (params )
449
449
Original file line number Diff line number Diff line change @@ -118,7 +118,7 @@ def main():
118
118
num_features = params .feature_dim ,
119
119
nhead = params .nhead ,
120
120
d_model = params .attention_dim ,
121
- num_classes = num_classes ,
121
+ num_classes = params . vocab_size ,
122
122
subsampling_factor = params .subsampling_factor ,
123
123
num_decoder_layers = params .num_decoder_layers ,
124
124
vgg_frontend = False ,
Original file line number Diff line number Diff line change @@ -182,7 +182,7 @@ def main():
182
182
183
183
model = Conformer (
184
184
num_features = params .feature_dim ,
185
- num_classes = num_classes ,
185
+ num_classes = params . vocab_size ,
186
186
subsampling_factor = params .subsampling_factor ,
187
187
d_model = params .dim_model ,
188
188
nhead = params .nhead ,
You can’t perform that action at this time.
0 commit comments