mirror of
https://github.com/k2-fsa/icefall.git
synced 2025-08-27 02:34:21 +00:00
Update pretrained.py and conformer_ctc.rst
This commit is contained in:
parent
9176da7574
commit
19891e26d5
@ -429,7 +429,6 @@ After downloading, you will have the following files:
|
|||||||
|-- README.md
|
|-- README.md
|
||||||
|-- data
|
|-- data
|
||||||
| |-- lang_bpe
|
| |-- lang_bpe
|
||||||
| | |-- Linv.pt
|
|
||||||
| | |-- HLG.pt
|
| | |-- HLG.pt
|
||||||
| | |-- bpe.model
|
| | |-- bpe.model
|
||||||
| | |-- tokens.txt
|
| | |-- tokens.txt
|
||||||
@ -447,10 +446,6 @@ After downloading, you will have the following files:
|
|||||||
6 directories, 11 files
|
6 directories, 11 files
|
||||||
|
|
||||||
**File descriptions**:
|
**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``
|
- ``data/lang_bpe/HLG.pt``
|
||||||
|
|
||||||
It is the decoding graph.
|
It is the decoding graph.
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
import argparse
|
import argparse
|
||||||
import logging
|
import logging
|
||||||
import math
|
import math
|
||||||
from pathlib import Path
|
|
||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
import k2
|
import k2
|
||||||
@ -57,19 +56,25 @@ def get_parser():
|
|||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--words-file",
|
"--words-file",
|
||||||
type=str,
|
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(
|
parser.add_argument(
|
||||||
"--HLG",
|
"--HLG",
|
||||||
type=str,
|
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(
|
parser.add_argument(
|
||||||
"--bpe-model",
|
"--bpe-model",
|
||||||
type=str,
|
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(
|
parser.add_argument(
|
||||||
@ -298,9 +303,6 @@ def main():
|
|||||||
|
|
||||||
if params.method == "ctc-decoding":
|
if params.method == "ctc-decoding":
|
||||||
logging.info("Use 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 = spm.SentencePieceProcessor()
|
||||||
bpe_model.load(params.bpe_model)
|
bpe_model.load(params.bpe_model)
|
||||||
max_token_id = bpe_model.get_piece_size() - 1
|
max_token_id = bpe_model.get_piece_size() - 1
|
||||||
@ -333,11 +335,6 @@ def main():
|
|||||||
"whole-lattice-rescoring",
|
"whole-lattice-rescoring",
|
||||||
"attention-decoder",
|
"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}")
|
logging.info(f"Loading HLG from {params.HLG}")
|
||||||
HLG = k2.Fsa.from_dict(torch.load(params.HLG, map_location="cpu"))
|
HLG = k2.Fsa.from_dict(torch.load(params.HLG, map_location="cpu"))
|
||||||
HLG = HLG.to(device)
|
HLG = HLG.to(device)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user