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
32
.github/scripts/test-python.sh
vendored
32
.github/scripts/test-python.sh
vendored
@@ -562,9 +562,39 @@ python3 ./python-api-examples/offline-decode-files.py \
|
||||
$repo/test_wavs/1.wav \
|
||||
$repo/test_wavs/8k.wav
|
||||
|
||||
lm_repo_url=https://huggingface.co/ezerhouni/icefall-librispeech-rnn-lm
|
||||
log "Download pre-trained RNN-LM model from ${lm_repo_url}"
|
||||
GIT_LFS_SKIP_SMUDGE=1 git clone $lm_repo_url
|
||||
lm_repo=$(basename $lm_repo_url)
|
||||
pushd $lm_repo
|
||||
git lfs pull --include "exp/no-state-epoch-99-avg-1.onnx"
|
||||
popd
|
||||
|
||||
bigram_repo_url=https://huggingface.co/vsd-vector/librispeech_bigram_sherpa-onnx-zipformer-large-en-2023-06-26
|
||||
log "Download bi-gram LM from ${bigram_repo_url}"
|
||||
GIT_LFS_SKIP_SMUDGE=1 git clone $bigram_repo_url
|
||||
bigramlm_repo=$(basename $bigram_repo_url)
|
||||
pushd $bigramlm_repo
|
||||
git lfs pull --include "2gram.fst"
|
||||
popd
|
||||
|
||||
log "Perform offline decoding with RNN-LM and LODR"
|
||||
python3 ./python-api-examples/offline-decode-files.py \
|
||||
--tokens=$repo/tokens.txt \
|
||||
--encoder=$repo/encoder-epoch-99-avg-1.onnx \
|
||||
--decoder=$repo/decoder-epoch-99-avg-1.onnx \
|
||||
--joiner=$repo/joiner-epoch-99-avg-1.onnx \
|
||||
--decoding-method=modified_beam_search \
|
||||
--lm=$lm_repo/exp/no-state-epoch-99-avg-1.onnx \
|
||||
--lodr-fst=$bigramlm_repo/2gram.fst \
|
||||
--lodr-scale=-0.5 \
|
||||
$repo/test_wavs/0.wav \
|
||||
$repo/test_wavs/1.wav \
|
||||
$repo/test_wavs/8k.wav
|
||||
|
||||
python3 sherpa-onnx/python/tests/test_offline_recognizer.py --verbose
|
||||
|
||||
rm -rf $repo
|
||||
rm -rf $repo $lm_repo $bigramlm_repo
|
||||
|
||||
log "Test non-streaming paraformer models"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user