Update pretrained.py and conformer_ctc.rst

This commit is contained in:
Mingshuang Luo 2021-10-14 19:51:36 +08:00
parent 9176da7574
commit 19891e26d5
2 changed files with 9 additions and 17 deletions

View File

@ -429,7 +429,6 @@ After downloading, you will have the following files:
|-- README.md
|-- data
| |-- lang_bpe
| | |-- Linv.pt
| | |-- HLG.pt
| | |-- bpe.model
| | |-- tokens.txt
@ -447,10 +446,6 @@ After downloading, you will have the following files:
6 directories, 11 files
**File descriptions**:
- ``data/lang_bpe/Linv.pt``
It is the lexicon file, with word IDs as labels and token IDs as aux_labels.
- ``data/lang_bpe/HLG.pt``
It is the decoding graph.

View File

@ -20,7 +20,6 @@
import argparse
import logging
import math
from pathlib import Path
from typing import List
import k2
@ -57,19 +56,25 @@ def get_parser():
parser.add_argument(
"--words-file",
type=str,
help="Path to words.txt " "Used only when method is not ctc-decoding",
help="""Path to words.txt.
Used only when method is not ctc-decoding.
""",
)
parser.add_argument(
"--HLG",
type=str,
help="Path to HLG.pt. " "Used only when method is not ctc-decoding",
help="""Path to HLG.pt.
Used only when method is not ctc-decoding.
""",
)
parser.add_argument(
"--bpe-model",
type=str,
help="Path to bpe.model. " "Used only when method is ctc-decoding.",
help="""Path to bpe.model.
Used only when method is ctc-decoding.
""",
)
parser.add_argument(
@ -298,9 +303,6 @@ def main():
if params.method == "ctc-decoding":
logging.info("Use CTC decoding")
if not Path(params.bpe_model).exists():
raise ValueError(f"The path to {params.bpe_model} doesn't exist!")
bpe_model = spm.SentencePieceProcessor()
bpe_model.load(params.bpe_model)
max_token_id = bpe_model.get_piece_size() - 1
@ -333,11 +335,6 @@ def main():
"whole-lattice-rescoring",
"attention-decoder",
]:
if not Path(params.HLG).exists():
raise ValueError(f"The path to {params.HLG} doesn't exist!")
if not Path(params.words_file).exists():
raise ValueError(f"The path to {params.words_file} doesn't exist!")
logging.info(f"Loading HLG from {params.HLG}")
HLG = k2.Fsa.from_dict(torch.load(params.HLG, map_location="cpu"))
HLG = HLG.to(device)