Add LODR support to online and offline recognizers (#2026)
This PR integrates LODR (Level-Ordered Deterministic Rescoring) support from Icefall into both online and offline recognizers, enabling LODR for LM shallow fusion and LM rescore. - Extended OnlineLMConfig and OfflineLMConfig to include lodr_fst, lodr_scale, and lodr_backoff_id. - Implemented LodrFst and LodrStateCost classes and wired them into RNN LM scoring in both online and offline code paths. - Updated Python bindings, CLI entry points, examples, and CI test scripts to accept and exercise the new LODR options.
This commit is contained in:
committed by
GitHub
parent
6122a678f5
commit
f0960342ad
@@ -21,6 +21,22 @@ rm sherpa-onnx-streaming-zipformer-en-2023-06-26.tar.bz2
|
||||
./sherpa-onnx-streaming-zipformer-en-2023-06-26/test_wavs/1.wav \
|
||||
./sherpa-onnx-streaming-zipformer-en-2023-06-26/test_wavs/8k.wav
|
||||
|
||||
or with RNN LM rescoring and LODR:
|
||||
|
||||
./python-api-examples/online-decode-files.py \
|
||||
--tokens=./sherpa-onnx-streaming-zipformer-en-2023-06-26/tokens.txt \
|
||||
--encoder=./sherpa-onnx-streaming-zipformer-en-2023-06-26/encoder-epoch-99-avg-1-chunk-16-left-64.onnx \
|
||||
--decoder=./sherpa-onnx-streaming-zipformer-en-2023-06-26/decoder-epoch-99-avg-1-chunk-16-left-64.onnx \
|
||||
--joiner=./sherpa-onnx-streaming-zipformer-en-2023-06-26/joiner-epoch-99-avg-1-chunk-16-left-64.onnx \
|
||||
--decoding-method=modified_beam_search \
|
||||
--lm=/path/to/lm.onnx \
|
||||
--lm-scale=0.1 \
|
||||
--lodr-fst=/path/to/lodr.fst \
|
||||
--lodr-scale=-0.1 \
|
||||
./sherpa-onnx-streaming-zipformer-en-2023-06-26/test_wavs/0.wav \
|
||||
./sherpa-onnx-streaming-zipformer-en-2023-06-26/test_wavs/1.wav \
|
||||
./sherpa-onnx-streaming-zipformer-en-2023-06-26/test_wavs/8k.wav
|
||||
|
||||
(2) Streaming paraformer
|
||||
|
||||
curl -SL -O https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/sherpa-onnx-streaming-paraformer-bilingual-zh-en.tar.bz2
|
||||
@@ -186,6 +202,22 @@ def get_args():
|
||||
""",
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
"--lodr-fst",
|
||||
metavar="file",
|
||||
type=str,
|
||||
default="",
|
||||
help="Path to LODR FST model. Used only when --lm is given.",
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
"--lodr-scale",
|
||||
metavar="lodr_scale",
|
||||
type=float,
|
||||
default=-0.1,
|
||||
help="LODR scale for rescoring.Used only when --lodr_fst is given.",
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
"--provider",
|
||||
type=str,
|
||||
@@ -320,6 +352,8 @@ def main():
|
||||
max_active_paths=args.max_active_paths,
|
||||
lm=args.lm,
|
||||
lm_scale=args.lm_scale,
|
||||
lodr_fst=args.lodr_fst,
|
||||
lodr_scale=args.lodr_scale,
|
||||
hotwords_file=args.hotwords_file,
|
||||
hotwords_score=args.hotwords_score,
|
||||
modeling_unit=args.modeling_unit,
|
||||
|
||||
Reference in New Issue
Block a user