feat: add mic example for better compatibility (#1909)

Co-authored-by: wanghsinche <wanghsinche>
This commit is contained in:
wanghsinche
2025-02-21 21:47:21 +08:00
committed by GitHub
parent 94728bfbee
commit 7774e35749
3 changed files with 229 additions and 1 deletions

View File

@@ -1,6 +1,8 @@
# Introduction
Note: You need `Node >= 18`.
Note: You need `Node >= 18`.
Note: For Mac M1 and other silicon chip series, do check the example `test-online-paraformer-microphone-mic.js`
This directory contains nodejs examples for [sherpa-onnx](https://github.com/k2-fsa/sherpa-onnx).
@@ -278,6 +280,25 @@ rm sherpa-onnx-streaming-paraformer-bilingual-zh-en.tar.bz2
node ./test-online-paraformer-microphone.js
```
## ./test-online-paraformer-microphone-mic.js
[./test-online-paraformer-microphone-mic.js](./test-online-paraformer-microphone-mic.js)
demonstrates how to do real-time speech recognition from microphone
with a streaming Paraformer model. In the code we use
[sherpa-onnx-streaming-paraformer-bilingual-zh-en](https://k2-fsa.github.io/sherpa/onnx/pretrained_models/online-paraformer/paraformer-models.html#csukuangfj-sherpa-onnx-streaming-paraformer-bilingual-zh-en-chinese-english).
It uses `mic` for better compatibility, do check its [npm](https://www.npmjs.com/package/mic) before running it.
You can use the following command to run it:
```bash
wget -q https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/sherpa-onnx-streaming-paraformer-bilingual-zh-en.tar.bz2
rm sherpa-onnx-streaming-paraformer-bilingual-zh-en.tar.bz2
node ./test-online-paraformer-microphone-mic.js
```
## ./test-online-paraformer.js
[./test-online-paraformer.js](./test-online-paraformer.js) demonstrates
how to decode a file using a streaming Paraformer model. In the code we use