This commit is contained in:
Yifan Yang 2023-10-17 19:15:55 +08:00
parent 6f0f358bcf
commit 2732349215
3 changed files with 19 additions and 20 deletions

View File

@ -7,14 +7,14 @@
This script exports a transducer model from PyTorch to ONNX. This script exports a transducer model from PyTorch to ONNX.
We use the pre-trained model from We use the pre-trained model from
https://huggingface.co/Zengwei/icefall-asr-librispeech-zipformer-2023-05-15 https://huggingface.co/yfyeung/icefall-asr-gigaspeech-zipformer-2023-10-17
as an example to show how to use this file. as an example to show how to use this file.
1. Download the pre-trained model 1. Download the pre-trained model
cd egs/librispeech/ASR cd egs/gigaspeech/ASR
repo_url=https://huggingface.co/Zengwei/icefall-asr-librispeech-zipformer-2023-05-15 repo_url=https://huggingface.co/yfyeung/icefall-asr-gigaspeech-zipformer-2023-10-17
GIT_LFS_SKIP_SMUDGE=1 git clone $repo_url GIT_LFS_SKIP_SMUDGE=1 git clone $repo_url
repo=$(basename $repo_url) repo=$(basename $repo_url)

View File

@ -24,7 +24,7 @@
Usage: Usage:
Note: This is a example for librispeech dataset, if you are using different Note: This is a example for gigaspeech dataset, if you are using different
dataset, you should change the argument values according to your dataset. dataset, you should change the argument values according to your dataset.
(1) Export to torchscript model using torch.jit.script() (1) Export to torchscript model using torch.jit.script()
@ -96,7 +96,7 @@ you can do:
cd /path/to/exp_dir cd /path/to/exp_dir
ln -s pretrained.pt epoch-9999.pt ln -s pretrained.pt epoch-9999.pt
cd /path/to/egs/librispeech/ASR cd /path/to/egs/gigaspeech/ASR
./zipformer/decode.py \ ./zipformer/decode.py \
--exp-dir ./zipformer/exp \ --exp-dir ./zipformer/exp \
--epoch 9999 \ --epoch 9999 \
@ -112,7 +112,7 @@ To use the generated file with `zipformer/decode.py` and `zipformer/streaming_de
cd /path/to/exp_dir cd /path/to/exp_dir
ln -s pretrained.pt epoch-9999.pt ln -s pretrained.pt epoch-9999.pt
cd /path/to/egs/librispeech/ASR cd /path/to/egs/gigaspeech/ASR
# simulated streaming decoding # simulated streaming decoding
./zipformer/decode.py \ ./zipformer/decode.py \
@ -144,17 +144,13 @@ Note: If you don't want to train a model from scratch, we have
provided one for you. You can get it at provided one for you. You can get it at
- non-streaming model: - non-streaming model:
https://huggingface.co/Zengwei/icefall-asr-librispeech-zipformer-2023-05-15 https://huggingface.co/yfyeung/icefall-asr-gigaspeech-zipformer-2023-10-17
- streaming model:
https://huggingface.co/Zengwei/icefall-asr-librispeech-streaming-zipformer-2023-05-17
with the following commands: with the following commands:
sudo apt-get install git-lfs sudo apt-get install git-lfs
git lfs install git lfs install
git clone https://huggingface.co/Zengwei/icefall-asr-librispeech-zipformer-2023-05-15 git clone https://huggingface.co/yfyeung/icefall-asr-gigaspeech-zipformer-2023-10-17
git clone https://huggingface.co/Zengwei/icefall-asr-librispeech-streaming-zipformer-2023-05-17
# You will find the pre-trained models in exp dir # You will find the pre-trained models in exp dir
""" """

View File

@ -40,7 +40,7 @@ import k2
import numpy as np import numpy as np
import sentencepiece as spm import sentencepiece as spm
import torch import torch
from asr_datamodule import LibriSpeechAsrDataModule from asr_datamodule import GigaSpeechAsrDataModule
from decode_stream import DecodeStream from decode_stream import DecodeStream
from kaldifeat import Fbank, FbankOptions from kaldifeat import Fbank, FbankOptions
from lhotse import CutSet from lhotse import CutSet
@ -682,7 +682,7 @@ def save_results(
@torch.no_grad() @torch.no_grad()
def main(): def main():
parser = get_parser() parser = get_parser()
LibriSpeechAsrDataModule.add_arguments(parser) GigaSpeechAsrDataModule.add_arguments(parser)
args = parser.parse_args() args = parser.parse_args()
args.exp_dir = Path(args.exp_dir) args.exp_dir = Path(args.exp_dir)
@ -823,15 +823,18 @@ def main():
num_param = sum([p.numel() for p in model.parameters()]) num_param = sum([p.numel() for p in model.parameters()])
logging.info(f"Number of model parameters: {num_param}") logging.info(f"Number of model parameters: {num_param}")
librispeech = LibriSpeechAsrDataModule(args) gigaspeech = GigaSpeechAsrDataModule(args)
test_clean_cuts = librispeech.test_clean_cuts() dev_cuts = gigaspeech.dev_cuts()
test_other_cuts = librispeech.test_other_cuts() test_cuts = gigaspeech.test_cuts()
test_sets = ["test-clean", "test-other"] dev_dl = gigaspeech.test_dataloaders(dev_cuts)
test_cuts = [test_clean_cuts, test_other_cuts] test_dl = gigaspeech.test_dataloaders(test_cuts)
for test_set, test_cut in zip(test_sets, test_cuts): test_sets = ["dev", "test"]
test_dls = [dev_dl, test_dl]
for test_set, test_dl in zip(test_sets, test_dls):
results_dict = decode_dataset( results_dict = decode_dataset(
cuts=test_cut, cuts=test_cut,
params=params, params=params,