-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Add JavaScript (WebAssembly) API for Omnilingual ASR CTC models #2781
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -203,10 +203,26 @@ rm sherpa-onnx-zipformer-ctc-zh-int8-2025-07-03.tar.bz2 | |||||||||||||||||||||||
| node ./test-offline-zipformer-ctc.js | ||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| ## ./test-offline-omnilingual-asr-ctc.js | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| [./test-offline-omnilingual-asr-ctc.js](./test-offline-omnilingual-asr-ctc.js) demonstrates | ||||||||||||||||||||||||
| how to decode a file with a Omnilingual ASR CTC model. In the code we use | ||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||||||||||||||||||
| [sherpa-onnx-omnilingual-asr-1600-languages-300M-ctc-int8-2025-11-12.tar.bz2](https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/sherpa-onnx-omnilingual-asr-1600-languages-300M-ctc-int8-2025-11-12.tar.bz2). | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| You can use the following command to run it: | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| ```bash | ||||||||||||||||||||||||
| wget https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/sherpa-onnx-omnilingual-asr-1600-languages-300M-ctc-int8-2025-11-12.tar.bz2 | ||||||||||||||||||||||||
| tar xvf sherpa-onnx-omnilingual-asr-1600-languages-300M-ctc-int8-2025-11-12.tar.bz2 | ||||||||||||||||||||||||
| rm sherpa-onnx-omnilingual-asr-1600-languages-300M-ctc-int8-2025-11-12.tar.bz2 | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| node ./test-offline-omnilingual-asr-ctc.js | ||||||||||||||||||||||||
|
Comment on lines
+215
to
+219
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The example commands repeat a very long filename, which can be hard to read and is prone to typos. Using a shell variable would make the example clearer and easier for users to adapt. Also,
Suggested change
|
||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| ## ./test-offline-wenet-ctc.js | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| [./test-offline-wenet-ctc.js](./test-offline-wenet-ctc.js) demonstrates | ||||||||||||||||||||||||
| how to decode a file with a Wenet CTC model. In the code we use | ||||||||||||||||||||||||
| how to decode a file with a WeNet CTC model. In the code we use | ||||||||||||||||||||||||
| [sherpa-onnx-wenetspeech-yue-u2pp-conformer-ctc-zh-en-cantonese-int8-2025-09-10.tar.bz2](https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/sherpa-onnx-wenetspeech-yue-u2pp-conformer-ctc-zh-en-cantonese-int8-2025-09-10.tar.bz2). | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| You can use the following command to run it: | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| // Copyright (c) 2025 Xiaomi Corporation (authors: Fangjun Kuang) | ||
| // | ||
| const fs = require('fs'); | ||
| const {Readable} = require('stream'); | ||
| const wav = require('wav'); | ||
|
Comment on lines
+3
to
+5
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
| const sherpa_onnx = require('sherpa-onnx'); | ||
|
|
||
| function createOfflineRecognizer() { | ||
| let config = { | ||
| modelConfig: { | ||
| omnilingual: { | ||
| model: | ||
| './sherpa-onnx-omnilingual-asr-1600-languages-300M-ctc-int8-2025-11-12/model.int8.onnx', | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The directory path |
||
| }, | ||
| tokens: | ||
| './sherpa-onnx-omnilingual-asr-1600-languages-300M-ctc-int8-2025-11-12/tokens.txt', | ||
| } | ||
| }; | ||
|
|
||
| return sherpa_onnx.createOfflineRecognizer(config); | ||
| } | ||
|
|
||
| const recognizer = createOfflineRecognizer(); | ||
| const stream = recognizer.createStream(); | ||
|
|
||
| const waveFilename = | ||
| './sherpa-onnx-omnilingual-asr-1600-languages-300M-ctc-int8-2025-11-12/test_wavs/en.wav'; | ||
| const wave = sherpa_onnx.readWave(waveFilename); | ||
| stream.acceptWaveform(wave.sampleRate, wave.samples); | ||
|
|
||
| recognizer.decode(stream); | ||
| const text = recognizer.getResult(stream).text; | ||
| console.log(text); | ||
|
|
||
| stream.free(); | ||
| recognizer.free(); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The script repeats a long model filename and directory name, which makes it harder to read and maintain. Using a variable for these repeated strings would make the script cleaner and less error-prone. Additionally, the
vflag intar xvfis verbose for CI logs;xfis generally sufficient.