Streaming (causal) Zipformer2 model for Mandarin Chinese ASR, trained on
AISHELL-1.
Trained with
icefall using pruned RNN-T loss.
Evaluated using greedy search, chunk-size=16, left-context=64.
1import torch
2from zipformer import Zipformer2 # from icefall
3
4checkpoint = torch.load("pretrained.pt", map_location="cpu")
5model.load_state_dict(checkpoint["model"])
6model.eval()
1# Clone icefall
2git clone https://github.com/k2-fsa/icefall
3cd icefall/egs/aishell/ASR
4
5# Greedy search inference on a wav file
6python zipformer/pretrained.py \
7 --checkpoint /path/to/pretrained.pt \
8 --tokens /path/to/tokens.txt \
9 --causal 1 \
10 --chunk-size 16 \
11 --left-context-frames 64 \
12 --method greedy_search \
13 /path/to/audio.wav
sherpa-onnx supports streaming inference using the ONNX files directly, with Python, C++, Android, iOS, and more.
1pip install sherpa-onnx
2
3python -c "
4import sherpa_onnx
5recognizer = sherpa_onnx.OnlineRecognizer.from_transducer(
6 encoder='encoder-epoch-30-avg-9-chunk-16-left-64.onnx',
7 decoder='decoder-epoch-30-avg-9-chunk-16-left-64.onnx',
8 joiner='joiner-epoch-30-avg-9-chunk-16-left-64.onnx',
9 tokens='tokens.txt',
10 num_threads=4,
11 decoding_method='greedy_search',
12)
13"
1@inproceedings{yao2023zipformer,
2 title={Zipformer: A faster and better encoder for automatic speech recognition},
3 author={Yao, Zengwei and Guo, Liyong and Yang, Xiaoyu and Kang, Wei and Lhotse, Daniel and Yang, Fangjun and Wang, Wei and Povey, Daniel},
4 booktitle={ICLR},
5 year={2024}
6}
7
8@inproceedings{bu2017aishell,
9 title={AISHELL-1: An open-source Mandarin speech corpus and a speech recognition baseline},
10 author={Bu, Hui and Du, Jiayu and Na, Xingyu and Wu, Bengu and Zheng, Hao},
11 booktitle={Proceedings of OCOCOSDA},
12 year={2017}
13}