modelscope/FunASR

GitHub: modelscope/FunASR

FunASR 是一款工业级语音识别工具包,提供多语言 ASR、说话人分离、情绪检测与流式处理能力,支持从云端到边缘的全场景部署。

Stars: 19395 | Forks: 1950

([简体中文](./README_zh.md)|English|[日本語](./README_ja.md)|[한국어](./README_ko.md))

FunASR

工业级语音识别。高达 340 倍实时速度,比 Whisper 快 26 倍。支持 50+ 种语言。
说话人分离 · 情绪检测 · 流式处理 · 一次 API 调用

PyPI Stars Downloads Docs

modelscope%2FFunASR | Trendshift

快速开始 · Colab · 基准测试 · 模型选择 · 迁移指南 · 使用案例 · 部署矩阵 · 模型 · Agent 集成 · 文档 · 参与贡献

## 快速开始 [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/modelscope/FunASR/blob/main/examples/colab/funasr_quickstart.ipynb) 没有本地环境?打开 [Colab 快速开始](./examples/colab/) 来转写公开示例,或在浏览器中上传您自己的音频。 ``` pip install torch torchaudio pip install funasr ``` **旗舰模型 — Fun-ASR-Nano** (LLM-ASR,支持 31 种语言;默认推荐,需要 GPU): ``` from funasr import AutoModel model = AutoModel(model="FunAudioLLM/Fun-ASR-Nano-2512", device="cuda") result = model.generate(input="https://isv-data.oss-cn-hangzhou.aliyuncs.com/ics/MaaS/ASR/test_audio/asr_example_zh.wav") print(result[0]["text"]) # 欢迎大家来体验达摩院推出的语音识别模型。 ``` 在 CPU 上运行(或为了一次性处理多语言和情绪),请使用 **SenseVoice** — 它还会返回说话人分离和时间戳: ``` from funasr import AutoModel from funasr.utils.postprocess_utils import rich_transcription_postprocess model = AutoModel(model="iic/SenseVoiceSmall", vad_model="fsmn-vad", spk_model="cam++", device="cuda") # use device="cpu" if you don't have a GPU result = model.generate( input="https://isv-data.oss-cn-hangzhou.aliyuncs.com/ics/MaaS/ASR/test_audio/asr_example_zh.wav", batch_size_s=300, ) # 一次调用即可返回带有 speaker id 和 timestamps 的 VAD segments — 随意渲染它们: for seg in result[0]["sentence_info"]: print(f"[{seg['start']/1000:.1f}s] Speaker {seg['spk']}: {rich_transcription_postprocess(seg['sentence'])}") ``` **输出** — 带有说话人标签、时间戳和标点符号的结构化文本: ``` [0.6s] Speaker 0: 欢迎大家来体验达摩院推出的语音识别模型 ``` 就是这样。**一个模型,一次调用** — VAD 分段、语音识别、标点恢复、说话人分离全部自动完成。 ### 扩展与部署旗舰模型 在大规模场景下,使用 vLLM 加速 Fun-ASR-Nano(批处理): ``` from funasr.auto.auto_model_vllm import AutoModelVLLM model = AutoModelVLLM(model="FunAudioLLM/Fun-ASR-Nano-2512", tensor_parallel_size=1) results = model.generate(["audio1.wav", "audio2.wav"], language="auto") ``` ### 为什么选择 FunASR? Whisper 是一个单一的模型;**FunASR 是一个工具包** — 您可以为每个任务选择合适的模型:**Fun-ASR-Nano**(旗舰 LLM-ASR,GPU,搭配 vLLM 达到 340 倍实时速度,31 种语言),**SenseVoice**(对 CPU 友好,支持情绪和音频事件),**Paraformer**(低延迟流式处理)。下表展示了该工具包相较于单一 Whisper 模型所提供的功能 — 每项能力都标明了提供该能力的模型: | | FunASR (工具包) | Whisper | Cloud APIs | |---|---|---|---| | 最高速度 | **340 倍实时** (Fun-ASR-Nano + vLLM) | 13 倍实时 | ~1 倍实时 | | 说话人 ID | ✅ 内置 | ❌ 需要 pyannote | ✅ 额外付费 | | 情绪 | ✅ 通过 SenseVoice | ❌ | ❌ | | 语言 | 50+ (Qwen3-ASR 52, Nano 31) | 57 | 视情况而定 | | 流式处理 | ✅ WebSocket (Paraformer) | ❌ | ✅ | | CPU 可行性 | ✅ 17 倍实时 (SenseVoice) | ❌ 太慢 | N/A | | 自托管 | ✅ MIT 许可证 | ✅ MIT 许可证 | ❌ 仅限云端 | | 成本 | 免费 | 免费 | $0.006/分钟+ | 第一次尝试 FunASR?在搭建本地环境之前,请先使用 [Colab 快速开始](./examples/colab/)。正在选择第一个模型?请从[模型选择指南](./docs/model_selection.md)开始。打算从 Whisper 或云端 ASR 服务商迁移?请使用[迁移指南](./docs/migration_from_whisper.md)和[基准测试示例](./examples/migration/)来测试具有代表性的音频、映射功能并安全地进行部署。 ## 安装 ``` pip install funasr ```
从源码安装 / 环境要求 ``` git clone https://github.com/modelscope/FunASR.git && cd FunASR pip install -e ./ ``` 环境要求:Python ≥ 3.8。请先安装 PyTorch + torchaudio ([pytorch.org](https://pytorch.org/get-started/locally/)),然后执行 `pip install funasr`。
## Model Zoo | 模型 | 任务 | 语言 | 参数量 | 链接 | |-------|------|-----------|--------|-------| | **Fun-ASR-Nano** | ASR + 时间戳 | 31 种语言 | 800M | [⭐](https://www.modelscope.cn/models/FunAudioLLM/Fun-ASR-Nano-2512) [🤗](https://huggingface.co/FunAudioLLM/Fun-ASR-Nano-2512) | | **SenseVoiceSmall** | ASR + 情绪 + 事件 | zh/en/ja/ko/yue | 234M | [⭐](https://www.modelscope.cn/models/iic/SenseVoiceSmall) [🤗](https://huggingface.co/FunAudioLLM/SenseVoiceSmall) | | **Paraformer-zh** | ASR + 时间戳 | zh/en | 220M | [⭐](https://www.modelscope.cn/models/iic/speech_paraformer-large-vad-punc_asr_nat-zh-cn-16k-common-vocab8404-pytorch/summary) [🤗](https://huggingface.co/funasr/paraformer-zh) | | Paraformer-zh-streaming | 流式 ASR | zh/en | 220M | [⭐](https://modelscope.cn/models/iic/speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-online/summary) [🤗](https://huggingface.co/funasr/paraformer-zh-streaming) | | Qwen3-ASR | ASR,52 种语言 | 多语言 | 1.7B | [使用](examples/industrial_data_pretraining/qwen3_asr) | | GLM-ASR-Nano | ASR,17 种语言 | 多语言 | 1.5B | [使用](examples/industrial_data_pretraining/glm_asr) | | Whisper-large-v3 | ASR + 翻译 | 多语言 | 1550M | [使用](examples/industrial_data_pretraining/whisper) | | Whisper-large-v3-turbo | ASR + 翻译 | 多语言 | 809M | [使用](examples/industrial_data_pretraining/whisper) | | ct-punc | 标点恢复 | zh/en | 290M | [⭐](https://modelscope.cn/models/iic/punc_ct-transformer_cn-en-common-vocab471067-large/summary) [🤗](https://huggingface.co/funasr/ct-punc) | | fsmn-vad | VAD | zh/en | 0.4M | [⭐](https://modelscope.cn/models/iic/speech_fsmn_vad_zh-cn-16k-common-pytorch/summary) [🤗](https://huggingface.co/funasr/fsmn-vad) | | cam++ | 说话人分离 | — | 7.2M | [⭐](https://modelscope.cn/models/iic/speech_campplus_sv_zh-cn_16k-common/summary) [🤗](https://huggingface.co/funasr/campplus) | | emotion2vec+large | 情绪识别 | — | 300M | [⭐](https://modelscope.cn/models/iic/emotion2vec_plus_large/summary) [🤗](https://huggingface.co/emotion2vec/emotion2vec_plus_large) | ## 用法 ``` from funasr import AutoModel # 中文 production(VAD + ASR + punctuation + speaker) model = AutoModel(model="paraformer-zh", vad_model="fsmn-vad", punc_model="ct-punc", spk_model="cam++", device="cuda") result = model.generate(input="https://isv-data.oss-cn-hangzhou.aliyuncs.com/ics/MaaS/ASR/test_audio/asr_example_zh.wav", hotword="关键词 20") # Streaming real-time(逐块输入音频) import soundfile as sf model = AutoModel(model="paraformer-zh-streaming", device="cuda") audio, sr = sf.read("speech.wav", dtype="float32") # 16 kHz mono chunk_size = [0, 10, 5] # 600 ms chunks chunk_stride = chunk_size[1] * 960 cache = {} n_chunks = (len(audio) - 1) // chunk_stride + 1 for i in range(n_chunks): chunk = audio[i * chunk_stride : (i + 1) * chunk_stride] res = model.generate(input=chunk, cache=cache, is_final=(i == n_chunks - 1), chunk_size=chunk_size, encoder_chunk_look_back=4, decoder_chunk_look_back=1) if res[0]["text"]: print(res[0]["text"], end="", flush=True) # Emotion recognition model = AutoModel(model="emotion2vec_plus_large", device="cuda") result = model.generate(input="audio.wav", granularity="utterance") ``` ### CLI (对 Agent 友好) ``` # Transcribe audio(最简单) funasr audio.wav # JSON output(用于 AI agents) funasr audio.wav --output-format json # SRT subtitles funasr audio.wav --output-format srt --output-dir ./subs # Speaker diarization + timestamps funasr audio.wav --spk --timestamps -f json # Choose model 和 language funasr audio.wav --model paraformer --language zh # Batch transcribe funasr *.wav --output-format srt --output-dir ./output ``` 可用模型:`sensevoice` (默认), `paraformer`, `paraformer-en`, `fun-asr-nano` ## 部署 ``` # 兼容 OpenAI 的 API(推荐) pip install torch torchaudio pip install funasr vllm fastapi uvicorn python-multipart funasr-server --device cuda # → POST /v1/audio/transcriptions at localhost:8000 ``` 使用公开示例进行验证: ``` curl -L https://isv-data.oss-cn-hangzhou.aliyuncs.com/ics/MaaS/ASR/test_audio/BAC009S0764W0121.wav -o sample.wav curl http://localhost:8000/v1/audio/transcriptions \ -F file=@sample.wav \ -F model=sensevoice \ -F response_format=verbose_json ``` ``` # Docker streaming service docker pull registry.cn-hangzhou.aliyuncs.com/funasr_repo/funasr:funasr-runtime-sdk-online-cpu-0.1.12 ``` ### CPU / 边缘端 — llama.cpp / GGUF (无需 GPU,无需 Python) 在 CPU 和边缘设备上以**单一独立二进制文件**的形式运行 **SenseVoice / Paraformer / Fun-ASR-Nano** — 这对于 FunASR 的意义就如同 [whisper.cpp](https://github.com/ggml-org/whisper.cpp) 之于 Whisper,但在中文上的 **>CER(字错率)比 whisper.cpp 低约 3 倍**。内置 FSMN-VAD,运行时不依赖 Python。 ``` # 1) 从 Releases(Linux / macOS / Windows)中获取 prebuilt binary,然后: bash download-funasr-model.sh sensevoice ./gguf # or: paraformer | nano llama-funasr-sensevoice -m ./gguf/SenseVoiceSmall-f16.gguf --vad ./gguf/fsmn-vad.gguf -a audio.wav # → 欢迎大家来体验达摩院推出的语音识别模型 ``` **预构建二进制文件:** [Releases](../../releases) · **下载与快速开始:** [funasr.com/llama-cpp](https://www.funasr.com/llama-cpp.html) · **GGUF 模型:** [Hugging Face](https://huggingface.co/FunAudioLLM) · **文档与基准测试:** [runtime/llama.cpp/](./runtime/llama.cpp/) [OpenAI API 示例 →](./examples/openai_api/) · [Gradio 演示 →](./examples/openai_api/GRADIO.md) · [客户端方案 →](./examples/openai_api/CLIENTS.md) · [JavaScript/TypeScript 方案 →](./examples/openai_api/JAVASCRIPT.md) · [Kubernetes 模板 →](./examples/openai_api/kubernetes/) · [工作流方案 →](./examples/openai_api/WORKFLOWS.md) · [Postman 集合 →](./examples/openai_api/POSTMAN.md) · [OpenAPI 规范 →](./examples/openai_api/OPENAPI.md) · [安全指南 →](./examples/openai_api/SECURITY.md) · [部署矩阵 →](./docs/deployment_matrix.md) · [部署文档 →](./runtime/readme.md) · [Agent 集成 →](https://modelscope.github.io/FunASR/agent.html) ## 基准测试 | 模型 | 中文 CER ↓ | GPU 速度 | CPU 速度 | vs Whisper-large-v3 | |-------|------|-----------|-----------|-------------------| | **Fun-ASR-Nano** (vLLM) | **8.20%** | **340x** 实时 | — | 🚀 **快 26 倍** | | **SenseVoice-Small** | **7.81%** | **170x** 实时 | **17x** 实时 | 🚀 **快 13 倍** | | **Paraformer-Large** | 10.18% | **120x** 实时 | **15x** 实时 | 🚀 **快 9 倍** | | Whisper-large-v3-turbo | 21.71% | 46x 实时 | ❌ | 快 3.4 倍 | | Whisper-large-v3 | 20.02% | 13x 实时 | ❌ | 基准 | ## 最新动态 - 2026/06/20: **llama.cpp / GGUF runtime** — 在 CPU 和边缘端作为单一独立二进制文件运行 SenseVoice / Paraformer / Fun-ASR-Nano(一种 whisper.cpp 风格的替代方案),内置 FSMN-VAD,运行时不依赖 Python。提供 Linux / macOS / Windows 的预构建二进制文件 + **q8 量化模型(体积约为一半,精度相同)**。[runtime/llama.cpp/](./runtime/llama.cpp/) · [Releases](../../releases) - 2026/06/21: PyPI 上的 **v1.3.12** 版本 — 滚动修复更新 (qwen3-asr 语言代码、glm_asr、vLLM repetition_penalty)。`pip install --upgrade funasr` - 2026/05/24: **vLLM 推理引擎** — 为 Fun-ASR-Nano 提升 2-3 倍的 LLM 解码速度。支持带 VAD + 说话人分离的流式 WebSocket 服务。[指南 →](docs/vllm_guide.md) · [实时 WS 调优 →](docs/vllm_guide.md#67-production-concurrency-and-multi-process-deployment) · [API 稳定性检查清单 →](docs/vllm_guide.md#production-api-stability-checklist) - 2026/05/24: **动态 VAD** — 自适应静音阈值(默认开启)。保留完整短句,长段音频自动切分。[详情 →](docs/vllm_guide.md#附录dynamicstreamingvad) - 2026/05/24: **v1.3.3** — `funasr-server` CLI,兼容 OpenAI 的 API,用于 AI Agent 的 MCP Server。`pip install --upgrade funasr` - 2026/05/20: 添加 Qwen3-ASR (0.6B/1.7B) — 支持 52 种语言,自动检测。[用法](examples/industrial_data_pretraining/qwen3_asr) - 2026/05/20: 添加 GLM-ASR-Nano (1.5B) — 支持 17 种语言,支持方言。[用法](examples/industrial_data_pretraining/glm_asr) - 2026/05/19: Fun-ASR-Nano 和 SenseVoice 现已支持说话人分离。 - 2025/12/15: [Fun-ASR-Nano-2512](https://github.com/FunAudioLLM/Fun-ASR) — 支持 31 种语言,千万小时级训练数据。
历史更新 - 2024/10/10: 新增对 Whisper-large-v3-turbo 的支持。 - 2024/07/04: [SenseVoice](https://github.com/FunAudioLLM/SenseVoice) — ASR + 情绪 + 音频事件。 - 2024/01/30: FunASR 1.0 发布。
## 许可证 [MIT 许可证](./LICENSE) ## 引用 ``` @inproceedings{gao2023funasr, author={Zhifu Gao and others}, title={FunASR: A Fundamental End-to-End Speech Recognition Toolkit}, booktitle={INTERSPEECH}, year={2023} } ```
标签:ASR, 人工智能, 凭据扫描, 工具包, 流式语音处理, 深度学习, 用户模式Hook绕过, 语音识别, 请求拦截, 逆向工具