Support streaming zipformer CTC (#496)
* Support streaming zipformer CTC * test online zipformer2 CTC * Update doc of sherpa-onnx.cc * Add Python APIs for streaming zipformer2 ctc * Add Python API examples for streaming zipformer2 ctc * Swift API for streaming zipformer2 CTC * NodeJS API for streaming zipformer2 CTC * Kotlin API for streaming zipformer2 CTC * Golang API for streaming zipformer2 CTC * C# API for streaming zipformer2 CTC * Release v1.9.6
This commit is contained in:
@@ -37,7 +37,20 @@ git lfs pull --include "*.onnx"
|
||||
./sherpa-onnx-streaming-paraformer-bilingual-zh-en/test_wavs/3.wav \
|
||||
./sherpa-onnx-streaming-paraformer-bilingual-zh-en/test_wavs/8k.wav
|
||||
|
||||
(3) Streaming Conformer CTC from WeNet
|
||||
(3) Streaming Zipformer2 CTC
|
||||
|
||||
wget https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/sherpa-onnx-streaming-zipformer-ctc-multi-zh-hans-2023-12-13.tar.bz2
|
||||
tar xvf sherpa-onnx-streaming-zipformer-ctc-multi-zh-hans-2023-12-13.tar.bz2
|
||||
rm sherpa-onnx-streaming-zipformer-ctc-multi-zh-hans-2023-12-13.tar.bz2
|
||||
ls -lh sherpa-onnx-streaming-zipformer-ctc-multi-zh-hans-2023-12-13
|
||||
|
||||
./python-api-examples/online-decode-files.py \
|
||||
--zipformer2-ctc=./sherpa-onnx-streaming-zipformer-ctc-multi-zh-hans-2023-12-13/ctc-epoch-20-avg-1-chunk-16-left-128.onnx \
|
||||
--tokens=./sherpa-onnx-streaming-zipformer-ctc-multi-zh-hans-2023-12-13/tokens.txt \
|
||||
./sherpa-onnx-streaming-zipformer-ctc-multi-zh-hans-2023-12-13/test_wavs/DEV_T0000000000.wav \
|
||||
./sherpa-onnx-streaming-zipformer-ctc-multi-zh-hans-2023-12-13/test_wavs/DEV_T0000000001.wav
|
||||
|
||||
(4) Streaming Conformer CTC from WeNet
|
||||
|
||||
GIT_LFS_SKIP_SMUDGE=1 git clone https://huggingface.co/csukuangfj/sherpa-onnx-zh-wenet-wenetspeech
|
||||
cd sherpa-onnx-zh-wenet-wenetspeech
|
||||
@@ -51,12 +64,9 @@ git lfs pull --include "*.onnx"
|
||||
./sherpa-onnx-zh-wenet-wenetspeech/test_wavs/8k.wav
|
||||
|
||||
|
||||
|
||||
Please refer to
|
||||
https://k2-fsa.github.io/sherpa/onnx/index.html
|
||||
and
|
||||
https://k2-fsa.github.io/sherpa/onnx/pretrained_models/wenet/index.html
|
||||
to install sherpa-onnx and to download streaming pre-trained models.
|
||||
https://k2-fsa.github.io/sherpa/onnx/pretrained_models/index.html
|
||||
to download streaming pre-trained models.
|
||||
"""
|
||||
import argparse
|
||||
import time
|
||||
@@ -97,6 +107,12 @@ def get_args():
|
||||
help="Path to the transducer joiner model",
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
"--zipformer2-ctc",
|
||||
type=str,
|
||||
help="Path to the zipformer2 ctc model",
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
"--paraformer-encoder",
|
||||
type=str,
|
||||
@@ -112,7 +128,7 @@ def get_args():
|
||||
parser.add_argument(
|
||||
"--wenet-ctc",
|
||||
type=str,
|
||||
help="Path to the wenet ctc model model",
|
||||
help="Path to the wenet ctc model",
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
@@ -275,6 +291,16 @@ def main():
|
||||
hotwords_file=args.hotwords_file,
|
||||
hotwords_score=args.hotwords_score,
|
||||
)
|
||||
elif args.zipformer2_ctc:
|
||||
recognizer = sherpa_onnx.OnlineRecognizer.from_zipformer2_ctc(
|
||||
tokens=args.tokens,
|
||||
model=args.zipformer2_ctc,
|
||||
num_threads=args.num_threads,
|
||||
provider=args.provider,
|
||||
sample_rate=16000,
|
||||
feature_dim=80,
|
||||
decoding_method="greedy_search",
|
||||
)
|
||||
elif args.paraformer_encoder:
|
||||
recognizer = sherpa_onnx.OnlineRecognizer.from_paraformer(
|
||||
tokens=args.tokens,
|
||||
|
||||
Reference in New Issue
Block a user