FunASR Speech Recognition Toolkit
repository·main·Indexed 12 days ago
https://github.com/modelscope/funasrAn industrial-grade speech recognition toolkit for offline, streaming, and edge deployment. It supports ASR, VAD, punctuation, speaker diarization, emotion recognition, and audio-event detection. Features include the AutoModel class for inference, support for multi-language models like Qwen3-ASR and GLM-ASR-Nano, and tools for speaker embedding extraction and model training via torchrun.
What's inside FunASR
- FunASR on llama.cpp allows running FunASR models on the ggml stack. This enables execution on CPU, edge devices, and environments without a Python runtime or GPU. It uses quantized weights (GGUF format) to provide a lightweight alternative to PyTorch/ONNX/vLLM paths, making it suitable for laptops, phones, and embedded C/C++ applications.
Overview of the M2MeT2.0 Challenge
mainThe M2MeT2.0 (Multi-Channel Multi-Party Meeting Transcription) challenge is a specialized task focused on speaker-attributed automatic speech recognition (ASR). Unlike previous iterations that were speaker-independent, M2MeT2.0 requires systems to solve the 'who spoke what and when' problem.
Core Tasks
- Speaker Diarization: Identifying who spoke when during a meeting.
- Multi-speaker ASR: Transcribing speech from multiple speakers simultaneously, specifically addressing challenges like overlapping speech and acoustic interference.
Challenge Tracks
- Fixed training conditions
- Open training conditions
Overview of FunASR on llama.cpp / GGUF runtime
mainThe
runtime/llama.cppdirectory provides a C++ / ggml runtime designed to run FunASR models (Fun-ASR-Nano, SenseVoiceSmall, and Paraformer) on CPU and edge devices without requiring PyTorch or Python. It uses quantized GGUF weights (2–8 bit) and leverages CPU SIMD for efficient inference on hardware like laptops, phones, or Raspberry Pi.Supported Models
Model Head / Decoder Autoregressive? Output Units Fun-ASR-Nano adaptor + Qwen3-0.6B LLM yes (LLM) Qwen3 BPE SenseVoiceSmall CTC no spectok BPE (25055) Paraformer CIF + SAN-M decoder no (parallel) char/BPE (8404) Directory Structure
Each model has its own directory containing llama.cpp example sources, a GGUF export script, and model-specific documentation:
fun-asr-nano/:funasr-cli,funasr-encoder,funasr-embd,export_encoder_gguf.pysensevoice/:funasr-sensevoice,export_sensevoice_gguf.py,detok.pyparaformer/:funasr-paraformer,export_paraformer_gguf.py,detok_paraformer.py
Overview of FunASR Service Deployment Options
mainFunASR provides several community-developed software packages to facilitate industrial deployment. The available service types include:
- Chinese Offline Transcription (CPU): For long-form audio/video to punctuated text.
- Chinese Real-time Speech Dictation (CPU): For low-latency, high-precision real-time transcription.
- English Offline Transcription (CPU): For English-language long-form transcription.
- Chinese Offline Transcription (GPU): High-performance version for large-scale offline tasks.
These services are designed to bridge the gap between raw models and production-ready business applications.
Overview of SenseVoice
mainSenseVoice is a speech foundation model designed for comprehensive speech understanding. It provides high-precision capabilities across several domains:
- Multilingual Automatic Speech Recognition (ASR): Supports over 50 languages (trained on 400k+ hours of data), outperforming Whisper in several benchmarks, particularly for Chinese and Cantonese.
- Rich Transcription: Includes advanced Speech Emotion Recognition (SER) and Acoustic Event Detection (AED) (e.g., detecting music, applause, laughter, coughing, etc.).
- Efficient Inference: Uses a non-autoregressive end-to-end framework. The
SenseVoice-Smallmodel is optimized for low latency (e.g., ~70ms for 10s of audio), making it significantly faster than Whisper-Large. - Deployment: Supports Python, C++, HTML, Java, and C# clients, with pipelines for multi-concurrent request handling.
Compare FunASR (llama.cpp/GGUF) vs whisper.cpp for Chinese ASR
mainThis benchmark compares the FunASR llama.cpp runtime against whisper.cpp for Mandarin Chinese speech recognition on CPU.
Key Findings for Chinese ASR on CPU:
- Accuracy: FunASR is approximately 2.7× more accurate than whisper.cpp across all model tiers.
- Speed: FunASR models (SenseVoiceSmall and Paraformer) achieve ~20-21× real-time speed, significantly outperforming whisper.cpp.
- Model Tiers:
- Fun-ASR-Nano: Highest accuracy (uses an autoregressive 0.6B LLM decoder).
- SenseVoiceSmall: High speed (~20× RTF) and includes language ID, emotion, and audio-event detection.
- Paraformer: High speed (~21× RTF) and specialized for Mandarin.
Comparison Summary (Micro-CER ↓):
System CER (approx) Speed (RTF) FunASR SenseVoiceSmall ~8% ~20× FunASR Paraformer ~10% ~21× whisper.cpp base ~31% 9.9× whisper.cpp small ~22% 4.6× whisper.cpp large-v3-turbo ~23% 3.2× Explore the FunASR Model Zoo
mainFunASR provides a variety of pre-trained models for speech processing tasks, including speech recognition, speaker diarization, punctuation restoration, and voice activity detection (VAD). Models are available on both ModelScope (⭐) and HuggingFace (🤗).
Available Speech Recognition Models
Model Name Task Details Training Data Parameters paraformer-zhSpeech recognition (non-streaming, with timestamps) 60,000h Mandarin 220M paraformer-zh-spkSpeech recognition with speaker diarization (non-streaming, with timestamps) 60,000h Mandarin 220M paraformer-zh-onlineStreaming speech recognition 60,000h Mandarin 220M paraformer-enSpeech recognition (non-streaming, with timestamps) 50,000h English 220M conformer-enSpeech recognition (non-streaming) 50,000h English 220M Supporting Models
Model Name Task Details Training Data Parameters ct-puncPunctuation restoration Mandarin & English 1.1G fsmn-vadVoice Activity Detection (VAD) Mandarin & English 0.4M fa-zhTimestamp prediction 5,000h Mandarin 38M For a complete list and detailed dataset information, visit the ModelScope Speech Recognition task page.
Use the FunASR OpenAI-Compatible API
mainThe FunASR speech API provides an OpenAI-compatible interface for audio transcription. You can use the provided
openapi.jsonto inspect, mock, or import the API into various tools like Swagger Editor, Redoc, Postman, or workflow engines like Dify and n8n. For client generation, ensure the multipartfilefield is mapped to a binary upload.Server URL Configuration: Replace the default local examples (
http://localhost:8000orhttp://funasr-api:8000) with the actual URL reachable from your application or runtime.FunASR Integration Features
mainWhen using FunASR via its API, you can leverage the following capabilities:
- Language Support: 50+ languages including Chinese dialects, English, Japanese, and Korean.
- Speaker Diarization: Enable via
spk=true. - Word-level Timestamps: Available when using
response_format="verbose_json". - Hotword Boosting: Support for improving recognition of specific terms.
- Performance: Up to 170x realtime speed, fully local, and MIT licensed.
Overview of FunASR models and capabilities
mainFunASR is a toolkit rather than a single model, offering different models optimized for specific use cases:
- Fun-ASR-Nano: Optimized for speed (up to 340x real-time with vLLM). Supports Chinese, English, Japanese, and Chinese dialects/accents. Best for GPU deployment.
- Fun-ASR-MLT-Nano: Supports 31 languages.
- SenseVoiceSmall: Provides ASR for 5 languages along with emotion and audio event recognition. Highly efficient on CPU (17x real-time).
- Paraformer: Designed for low-latency streaming via WebSocket.
Key advantages over Whisper include built-in VAD + Speaker ID pipelines, emotion recognition, and significantly higher speeds on both CPU and GPU.
Understand JSONL streaming and batching behavior
mainWhen running FunASR ONNX binaries in batch or streaming modes, keep the following behaviors in mind:
- Output Streams: JSON records are written to
stdout. Diagnostic information and progress logs are written tostderr. - Input Processing: When using a
wav.scpfile, one JSON line is output for every successfully completedkey. - Concurrency and Ordering: For RTF (Real-Time Factor) binaries, single JSON lines are guaranteed not to be interleaved by multiple threads. However, the completion order of different tasks is not guaranteed. Always use the
keyfield to associate results with inputs rather than relying on line order. - Default Format: If
--output-formatis not specified, it defaults to--output-format log(the original logging behavior).
- Output Streams: JSON records are written to
Understand the FunASR + vLLM inference architecture
mainThe FunASR vLLM integration splits the ASR model into two distinct parts to leverage vLLM's high-throughput capabilities:
- PyTorch Component (Single GPU): Handles the audio frontend. It processes audio through an
Audio Encoder(e.g., SenseVoice/Whisper) and anAdaptor(Transformer/MLP) to produce Audio Embeddings. - vLLM Engine: Receives the audio embeddings and text prompts. It uses PagedAttention, Continuous Batching, and Tensor Parallelism to decode the text using the LLM (e.g., Qwen3-0.6B or Llama-2B).
Key Technical Concepts:
- EmbedsPrompt: Instead of passing token IDs, Fun-ASR-Nano passes the continuous audio embedding vectors directly to vLLM by setting
enable_prompt_embeds=True. The audio embeddings are concatenated with text embeddings in the sequence dimension. - Weight Separation: LLM weights are extracted from the original
model.ptand converted to HuggingFacesafetensorsformat for vLLM compatibility. - Performance: vLLM provides significantly higher throughput (RTFx 340+) compared to standard PyTorch
generate()(RTFx ~20) due to optimized KV Cache management and batching.
- PyTorch Component (Single GPU): Handles the audio frontend. It processes audio through an