feat(asr): add pluggable ONNX streaming backend and model registry

Add a second backend (sherpa-onnx) alongside llama.cpp, so native
streaming models can be selected by ID from a JSON registry. All such
models share one adapter: only the model files and a few options differ.
Models now live under the app data directory and are fetched by
scripts/fetch-models.sh. Adding a model is a data change, not code.

Measured on the same audio: the streaming backend is ~35x cheaper in CPU
than Qwen3-ASR (0.10-0.12 vs 4.27 core-seconds per audio second), shows
the first caption at 0.48-1.44s, and matches its accuracy for zh/en.

新增 sherpa-onnx 流式后端,与 llama.cpp 并存;模型按注册表 id 从应用
数据目录加载。同族模型共用一个适配器,新增模型只改 data/models.json。
实测流式后端 CPU 约为 Qwen3-ASR 的 1/35,首个字幕 0.48~1.44s,中英
准确率持平。注意预编译库是旧 C++ ABI,必须走其 C API。
This commit is contained in:
blumia committed 2026-10-12 16:06:51 +08:00
1 parent 6d64987d64
commit bd921b1ac5
15 files changed
+869 -18

No files matched your search

+88
View File
@@ -0,0 +1,88 @@
{
"version": 1,
"comment": "live-caption 的模型注册表。新增模型 = 在这里加一条,不需要改代码。",
"models": [
{
"id": "zipformer-zh-2025",
"name": "中文流式(k2-fsa 官方 2025-06-30)",
"backend": "sherpa-online",
"languages": ["zh"],
"license": "Apache-2.0",
"note": "154MB,实测中文逐字正确;首个字幕 0.48s,约 0.10 核·秒/秒音频",
"files": {
"encoder": {
"name": "encoder.int8.onnx",
"url": "https://hf-mirror.com/csukuangfj/sherpa-onnx-streaming-zipformer-zh-int8-2025-06-30/resolve/main/encoder.int8.onnx"
},
"decoder": {
"name": "decoder.onnx",
"url": "https://hf-mirror.com/csukuangfj/sherpa-onnx-streaming-zipformer-zh-int8-2025-06-30/resolve/main/decoder.onnx"
},
"joiner": {
"name": "joiner.int8.onnx",
"url": "https://hf-mirror.com/csukuangfj/sherpa-onnx-streaming-zipformer-zh-int8-2025-06-30/resolve/main/joiner.int8.onnx"
},
"tokens": {
"name": "tokens.txt",
"url": "https://hf-mirror.com/csukuangfj/sherpa-onnx-streaming-zipformer-zh-int8-2025-06-30/resolve/main/tokens.txt"
}
},
"options": {}
},
{
"id": "xasr-zh-en-480",
"name": "中英流式(X-ASR-zh-en, 480ms)",
"backend": "sherpa-online",
"languages": ["zh", "en"],
"license": "Apache-2.0",
"note": "587MB,实测中英准确率与 Qwen3-ASR 持平;首个字幕 1.44s",
"files": {
"encoder": {
"name": "encoder-480ms.onnx",
"url": "https://hf-mirror.com/GilgameshWind/X-ASR-zh-en/resolve/main/deployment/models/chunk-480ms-model/encoder-480ms.onnx"
},
"decoder": {
"name": "decoder-480ms.onnx",
"url": "https://hf-mirror.com/GilgameshWind/X-ASR-zh-en/resolve/main/deployment/models/chunk-480ms-model/decoder-480ms.onnx"
},
"joiner": {
"name": "joiner-480ms.onnx",
"url": "https://hf-mirror.com/GilgameshWind/X-ASR-zh-en/resolve/main/deployment/models/chunk-480ms-model/joiner-480ms.onnx"
},
"tokens": {
"name": "tokens.txt",
"url": "https://hf-mirror.com/GilgameshWind/X-ASR-zh-en/resolve/main/deployment/models/chunk-480ms-model/tokens.txt"
}
},
"options": {}
},
{
"id": "nemotron35-560ms",
"name": "多语言流式(Nemotron 3.5, 560ms, 含日语)",
"backend": "sherpa-online",
"languages": ["en", "ja", "ko", "vi", "ru", "ar", "hi", "fr", "de", "es", "it", "pt", "nl", "tr", "uk", "zh"],
"license": "OpenMDW-1.1",
"note": "651MB,40 种语言 + 内置语言识别;实测中英日都可用但都有瑕疵",
"optionsHint": "language",
"files": {
"encoder": {
"name": "encoder.int8.onnx",
"url": "https://hf-mirror.com/csukuangfj2/sherpa-onnx-nemotron-3.5-asr-streaming-0.6b-560ms-int8-2026-06-11/resolve/main/encoder.int8.onnx"
},
"decoder": {
"name": "decoder.int8.onnx",
"url": "https://hf-mirror.com/csukuangfj2/sherpa-onnx-nemotron-3.5-asr-streaming-0.6b-560ms-int8-2026-06-11/resolve/main/decoder.int8.onnx"
},
"joiner": {
"name": "joiner.int8.onnx",
"url": "https://hf-mirror.com/csukuangfj2/sherpa-onnx-nemotron-3.5-asr-streaming-0.6b-560ms-int8-2026-06-11/resolve/main/joiner.int8.onnx"
},
"tokens": {
"name": "tokens.txt",
"url": "https://hf-mirror.com/csukuangfj2/sherpa-onnx-nemotron-3.5-asr-streaming-0.6b-560ms-int8-2026-06-11/resolve/main/tokens.txt"
}
},
"options": {}
}
]
}