Commit Graph
400 Commits
Author SHA1 Message Date
zhifu gao 7cdc280ee0 build: define NOMINMAX/_USE_MATH_DEFINES for MSVC (Windows portability) 2026-06-20 14:41:32 +08:00
zhifu gaoandLauraGPT 4a93f29333 docs: build note — copy funasr-common alongside the example (shared miniaudio audio loader) (#2996)
Co-authored-by: LauraGPT <[email protected]>
2026-06-20 14:14:55 +08:00
zhifu gao 66358c577e feat: B1 packaging — one-command download, standalone convert, CI-friendly CMake (#3000)
Make the runtime a downloadable product (whisper.cpp-style), no manual export needed:

- download-funasr-model.sh: one command to pull pre-converted GGUF from Hugging Face
  (FunAudioLLM/*-GGUF), incl. fsmn-vad for built-in --vad. No Python ML env required.
- convert-funasr-to-gguf.py: one-step HF/ModelScope checkpoint -> GGUF (wraps the
  validated export_*.py; discovered relative to itself so it works in any layout).
- CMakeLists.txt: standalone, CI-friendly top-level build. FetchContent pins llama.cpp
  (provides ggml + llama), static libs -> self-contained binaries in build/bin/, no
  hardcoded paths; builds on Linux/macOS/Windows x64/arm64. `cmake -B build && cmake --build build -j`.
- README: download-first + standalone-build quickstart; links to the HF GGUF repos.

Verified on Linux: all targets build via FetchContent (static, no shared-lib deps);
hf download -> run reproduces canonical output. Additive; runtime/llama.cpp/ only.
2026-06-20 14:14:49 +08:00
zhifu gao 27756664df fix: address FSMN-VAD review findings (portability + robustness) (#2999)
- funasr_vad.h: define M_PI fallback (not guaranteed on MSVC) for cross-platform CI;
  guard against audio shorter than one frame (empty fbank -> OOB in lfr);
  validate required GGUF tensors up front (fail with a message, not a segfault);
  shrink the no_alloc metadata context (512MB -> 16MB); drop a redundant ggml_cont
  on an already-contiguous row slice in the FSMN memory loop.
- export_vad_gguf.py: use a with-statement when reading am.mvn (no fd leak).

No behavior change: VAD segment boundaries are byte-identical on the 184-clip set.
2026-06-20 13:41:26 +08:00
zhifu gao e615ed0dc0 feat: built-in FSMN-VAD (--vad) for all three runtimes — single-binary segmentation (#2998)
Add a native ggml FSMN-VAD front end so the binaries segment long audio themselves,
with no Python at runtime. New `--vad fsmn-vad.gguf` flag on llama-funasr-cli,
llama-funasr-sensevoice and llama-funasr-paraformer runs FSMN-VAD (fbank + LFR + CMVN +
FSMN encoder + E2EVadModel state machine, in funasr-common/funasr_vad.h) and decodes
each speech segment, then concatenates.

- funasr-common/funasr_vad.h: single-header VAD; segment boundaries within ~10 ms of
  PyTorch fsmn-vad.generate on the 184-clip set (DEFAULT_SILENCE_SCHEDULE replicated,
  chunk-stepped silence schedule + speech_noise_thres 0.5).
- funasr-vad/: standalone VAD tool (wav -> [start_ms,end_ms] segments).
- export_vad_gguf.py: export FSMN-VAD encoder + CMVN to GGUF (1.7 MB, 24 tensors).
- BENCHMARKS.md: bare binary with built-in VAD reaches the reference end-to-end —
  full-184 micro-CER SenseVoice 8.01 / Paraformer 9.85 / Fun-ASR-Nano 8.30.

Additive only: no existing code is modified outside runtime/llama.cpp/.
2026-06-20 13:26:27 +08:00
zhifu gaoandLauraGPT a83e1d9c38 feat: accept any audio input (any rate/channels, wav/mp3/flac) via miniaudio (#2994)
* feat(runtime): accept any audio (any sample-rate/channels, wav/mp3/flac) via miniaudio

Replaces the 16k-mono-PCM16-only WAV reader with a miniaudio-based loader
(funasr-common/funasr_audio.h) that decodes wav/mp3/flac at any sample rate and
channel count, resampling to 16 kHz mono. Verified: a 44.1k stereo file and an 8k
mono file both transcribe correctly across cli/sensevoice/paraformer.

* fix(audio): inline loader (avoid duplicate symbols), null-path guard, check decoder read result (gemini review)

---------

Co-authored-by: LauraGPT <[email protected]>
2026-06-19 22:40:02 +08:00
zhifu gaoandLauraGPT 842e62f875 docs: CPU benchmark vs whisper.cpp (Chinese ASR) (#2992)
* docs: add CPU benchmark vs whisper.cpp (FunASR is more accurate & faster on Chinese)

* docs(benchmark): clarify size column; add reproduction scripts (compute_cer.py + method README)

* docs(benchmark): finalize — canonical micro-CER+normalize_zh, full 184, fp32-ref/Q8-runtime dual values, whisper full set, transparency footnotes

---------

Co-authored-by: LauraGPT <[email protected]>
2026-06-19 22:26:14 +08:00
zhifu gaoandLauraGPT b7da5cc706 Add llama.cpp / GGUF runtime for FunASR models (#2988)
* Add llama.cpp/GGUF runtime for Fun-ASR-Nano, SenseVoice and Paraformer

Run FunASR models entirely on the llama.cpp / ggml stack: CPU / edge, single
binary, no Python at runtime, quantized GGUF weights (like whisper.cpp for
Whisper). Adds runtime/llama.cpp/ with three models sharing a common ggml SAN-M
encoder / FSMN / attention and kaldi fbank front end:

- fun-asr-nano : SAN-M encoder + adaptor + Qwen3-0.6B LLM (audio embeds injected
  via llama_decode embedding input, llava/mtmd style); integrated WAV->text CLI.
- sensevoice   : SAN-M encoder + CTC; WAV->CTC ids.
- paraformer   : SAN-M encoder + CIF predictor + SAN-M decoder (non-autoregressive).

Each ships a GGUF export script and a README (architecture, quickstart, accuracy,
gotchas). Validated against the PyTorch reference (encoder cosine ~1.0; SenseVoice
CTC ids identical; Paraformer text identical; Fun-ASR-Nano CER within 0.02% under
identical conditions). Adds a new directory only; no existing code is modified.

* docs: add comprehensive design document (architecture, GGUF format, validation, gotchas)

* docs: link README to DESIGN.md

* fix: address code review (WAV ch/bits validation, chunk guard, null/leak checks)

Fixes gemini-code-assist findings: validate channels/bits in the WAV reader
(reject non-16-bit/zero-channel instead of dividing by zero), guard chunk size
>=1, null-check fopen/llama_context, and fclose/ggml_free on all paths.

---------

Co-authored-by: LauraGPT <[email protected]>
2026-06-19 12:06:42 +08:00
zhifu gaoandLauraGPT dd9487bcc3 docs: python wss server now supports multiple concurrent clients (#2985)
funasr_wss_server.py was upgraded to handle multiple clients with
non-blocking inference and per-stage concurrency semaphores
(--concurrent_vad/asr_online/asr_offline/punc/sv), but quick_start docs
still said only a single client is supported. Update both EN and ZH.

Co-authored-by: LauraGPT <[email protected]>
2026-06-17 23:40:01 +08:00
a3fb72e9cb feat(runtime): add sentence-level timestamps to WebSocket 2pass server (#2969)
* 修改FunASR实时识别框架,实时识别时2pass模式下支持框架层面返回句子级别的时间戳,单位毫秒

* 修改FunASR实时识别框架,实时识别时2pass模式下支持框架层面返回句子级别的时间戳,单位毫秒

* 新增识别相关标识字段

* 2pass模式返回字段新增对话开始时间戳

* 生产适配

* Update runtime/websocket/bin/websocket-server-2pass.cpp

svs_lang=auto

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>

---------

Co-authored-by: pengkun <[email protected]>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
2026-06-10 01:58:31 -07:00
游雁 aad31f5e02 Revert "fix(runtime): 4 memory safety bugs in onnxruntime C++ code"
This reverts commit be26718559.
2026-05-24 00:23:17 +08:00
游雁 eb5d0574f2 Revert "fix(runtime/go): websocket client premature close in offline mode (#2834)"
This reverts commit 13b244d4c2.
2026-05-24 00:23:17 +08:00
imdenny 690280581b fix(onnxruntime): Fix Windows MSVC compilation errors (#2841)
* fix(onnxruntime): Fix Windows MSVC compilation errors

- Fix CMake syntax warning in src/CMakeLists.txt (message function quoting)

- Replace Python-style 'and' with C++ '&&' in ct-transformer-online.cpp

- Fix ssize_t redefinition conflict between kaldi and openfst on Windows

- Update yaml-cpp CMake policies from OLD to NEW for modern CMake compatibility

These changes enable successful compilation with MSVC on Windows (VS 2022)

 while maintaining compatibility with other platforms.

Tested with: Visual Studio 2022, Windows 11, CMake 3.x

* Add realtime mic app and optional FFmpeg build
2026-05-24 00:21:35 +08:00
游雁 13b244d4c2 fix(runtime/go): websocket client premature close in offline mode (#2834)
Move offline_msg_done signal after the ReadMessage loop exits (when
server closes connection), not on first message receipt. Previously,
multi-segment audio would only get the first segment transcribed
before the client closed the connection.
2026-05-24 00:18:40 +08:00
游雁 be26718559 fix(runtime): 4 memory safety bugs in onnxruntime C++ code
- #2848: encoder_out_lens int32/int64 type mismatch (heap-buffer-overflow)
- #2845: memory leak in FunTpassInferBuffer (missing delete[] for buff/len)
- #2846: buffer leak in Audio::FfmpegLoad error paths (av_freep before avio_context_free)
- #2847: AudioFrame copy constructor missing data/global_start/global_end (double-free risk)
2026-05-24 00:16:26 +08:00
ZZUZSL1024 a397d0b27e Codex/create training and inference scripts (#2791)
* Update funasr_wss_server.py

* Update funasr_wss_client.py

* Add files via upload

* Update funasr_wss_server.py

* Update funasr_wss_client.py

* Add LoRA Paraformer README
2026-02-04 19:49:29 +08:00
AllenDouandzixiao 36656aa8f7 when mode is 2pass and test audio is vad_example.wav, we should give more time to websocket connection to recv message, or funasr_wss_client.py's websocket.recv() will cause exception occasionally because connection has been closed. (#2772)
Co-authored-by: zixiao <[email protected]>
2026-01-07 21:00:24 +08:00
msly c253fe7d7a Add bounds check for msg_stamp before timestamp processing (#2760)
* Add bounds check for msg_stamp before timestamp processing

* avoids the extra layer of nesting
2026-01-01 15:12:00 +08:00
YAN XIANGJUN 995c8b090c Fix path mistake in FunASR/runtime/python /onnxruntime/README.md and fix python dependence mistake of funasr_onnx (#2710)
* Fix path mistake in FunASR/runtime/python /onnxruntime/README.md

“FunASR/funasr/runtime/python/onnxruntime”是一个不存在的路径,在执行“cd FunASR”之后,如果用户再执行“cd funasr/runtime/python/onnxruntime”会出现错误。

"FunASR/funasr/runtime/python/onnxruntime" is an invalid path. After executing "cd FunASR", if the user execute "cd funasr/runtime/python/onnxruntime", an error will occur.

* Change onnx to jieba in the setup.py of funasr_onnx
2025-12-14 21:55:35 +08:00
Flute fa9a6cdb1e 更新文档和运行脚本,修复文档拼写错误 (#2688)
* 更新运行脚本中的错误

现在魔搭社区已经由原来的damo转为了通义实验室的"iic",为避免重定向,更新脚本。

* 修复文档拼写错误和更新魔搭社区路径

现在魔搭社区已经由原来的damo转为了通义实验室的"iic",为避免重定向,更新脚本。拼写错误lagre->large
2025-10-01 14:44:28 +08:00
Gang Zhuo 6244b743a7 fix: crash when using online mode with uninitialized jieba (#2663)
Problem:
- Crash occurs with [punc_ct-transformer_cn-en-common-vocab471067-large-onnx](https://www.modelscope.cn/models/iic/punc_ct-transformer_cn-en-common-vocab471067-large-onnx) model
- Root cause: jieba is enabled but not properly initialized

Solution:
- Add jieba initialization before usage
2025-09-20 22:41:28 +08:00
Kyle He 82a07e2f6e fix: funasr_onnx pass run_options to ort (#2632) 2025-08-14 16:07:54 +08:00
nianjiuhuiyi 05c8eba11c Fix: 修复c++后端服务因为空数组的异常退出,以及c++的http服务在收到Ctrl+C信号后无法正常退出 (#2571)
* Fix: 修复c++后端,在持续接收请求过程中运行不定时长后,服务会因为segmentation fault挂掉

添加msg_stamp是否为空的判断,在某些特定请求中,msg_stamp可能为空,避免msg_stamp为空时,直接对其进行取值操作。

* Fix: 修复c++的http服务在收到Ctrl+C信号后无法正常退出的问题

在程序主动退出时,添加工作守卫的移除,确保在捕获Ctrl+C信号后,程序能正退退出。
2025-06-27 09:57:45 +08:00
Thirteen a3d6e48fe1 Update server.py (#2556)
Fix the error that occurs when there are no text elements in the audio and an exception is thrown.
2025-06-21 22:45:24 +08:00
lyblsgo 3ee9e8e3ba update runtime docs 2025-06-16 19:23:20 +08:00
Logan ab2148ec18 更新go client 的原生实现 (#2532) 2025-05-26 14:34:47 +08:00
王梦迪andwangmengdi06 9038340be7 修复Fsmn_vad_online多线程调用报错 (#2528)
* 缓存cmvn file加载结果,避免多次实例化WavFrontend时重复加载

* 修复Fsmn_vad_online并发调用报错

---------

Co-authored-by: wangmengdi06 <[email protected]>
2025-05-26 14:11:02 +08:00
TouchZZZandzjw eccf746847 fix: msg_stamp.size() is unsigned,should convert to int (#2523)
Co-authored-by: zjw <[email protected]>
2025-05-22 17:47:28 +08:00
王梦迪andwangmengdi06 fe588bc508 Fsmn_vad支持多线程并发调用 (#2519)
* 修复WavFrontend.fbank多线程调用下共享fbank_fn导致的bug

* Fsmn_vad支持多线程并发调用

---------

Co-authored-by: wangmengdi06 <[email protected]>
2025-05-20 16:10:59 +08:00
zhaomingwork ae013cf597 fix bug for core dump in http, use libboost as parse (#2509) 2025-05-08 23:52:09 +08:00
nianjiuhuiyi 0d6e6a2fb8 Fix: Spelling causes hotwords to not take effect (#2444)
The hotword passed by the client cannot take effect because of a spelling error.
2025-03-20 22:59:42 +08:00
辰冢 5052ca8bf0 Hotwords file needs to specify default utf-8 encoding. (#2379) 2025-02-12 16:13:08 +08:00
zhifu gao 3f8294b9d7 Revert "shfit to shift (#2266)" (#2336)
This reverts commit 1367973f98.
2024-12-25 17:16:11 +08:00
Rin Arakaki 1367973f98 shfit to shift (#2266) 2024-12-24 17:51:31 +08:00
majic31 ae7aff2e9c fix: solve problems in sensevoice_bin.py related to argmax and unique, as mentioned in issue #2331 (#2332) 2024-12-24 17:51:11 +08:00
majic31 23e7ddebcc Fix the variable name (#2328) 2024-12-24 10:00:14 +08:00
shixian a62cd7a3fd update sensevoice onnx 2024-12-20 10:50:51 +08:00
inisis c4412495bd add onnxslim reference (#2314) 2024-12-17 12:40:04 +08:00
Haitao 7263fb08e9 识别结果中有英语时,缺少空格或者第一个单词的问题 (#2284)
* Update ct-transformer-online.cpp

修复最后两个单词之间没有空格的问题

* Update ct-transformer-online.cpp

解决语音中连续两句英语,offline结果丢失第二句第一个单词的情况。
2024-12-13 13:47:15 +08:00
莫拉古 ae49b2a8e1 变量名写错了 (#2249) 2024-11-29 09:55:43 +08:00
Yabin Li 141df861cb Update websocket_protocol_zh.md 2024-11-20 15:22:59 +08:00
yijinsheng 2b747626c8 paraformer_large_offline triton运行bug 修复 2024-11-11 23:52:48 +08:00
Djraemon 7e9696f156 Fix audio format 2.0 (#2186)
* 添加了对音频文件扩展名是否为.mp3的补丁,是mp3格式则转化为wav格式

* 增加检测音频文件是否为mp3格式的补丁

* 完善对音频文件后缀名的检查,若文件后缀不是.wav,则转化为wav

* 增加音频文件后缀名检查;音频文件无效时抛出错误

* 在paraformer、vad两个模型中加入对音频文件后缀的检查,并将非wav格式转为wav格式

* 修改wav_path的数据类型,使demo能够顺利运行
2024-11-04 11:04:52 +08:00
雾聪 c540f7c831 update readme 2024-10-29 16:48:59 +08:00
雾聪 4f87e0b8f8 update readme 2024-10-29 15:06:40 +08:00
雾聪 1819303f5e support SenseVoiceSmall in 2pass mode 2024-10-29 11:40:18 +08:00
Djraemon a76f15c785 Fix audio format (#2159)
* 添加了对音频文件扩展名是否为.mp3的补丁,是mp3格式则转化为wav格式

* 增加检测音频文件是否为mp3格式的补丁

* 完善对音频文件后缀名的检查,若文件后缀不是.wav,则转化为wav

* 增加音频文件后缀名检查;音频文件无效时抛出错误
2024-10-21 13:30:45 +08:00
757d20b3e8 Fix typo (#2158)
* doc: Correct html5 download path error

* docs: fix typo

---------

Co-authored-by: wucan <[email protected]>
Co-authored-by: WuCan <[email protected]>
2024-10-21 13:30:04 +08:00
雾聪 1480dcf5d5 add GetInputNames GetOutputNames 2024-10-10 17:45:45 +08:00
雾聪 4d8e96f695 fix memmory leak of GetInputOutputInfo 2024-10-10 15:44:44 +08:00