Open-source speech recognition toolkit for training, inference, streaming ASR, VAD, punctuation, speaker diarization pipelines, and OpenAI-compatible/MCP serving.
Python asraudiochineseemotion-recognitionfunasrmcp-servermultilingual-asropenai-compatible-apiparaformerpunctuationpytorchreal-time-asrspeaker-diarizationspeech-recognitionspeech-to-textstreaming-asrtranscriptionvllmvoice-activity-detectionwhisper-alternative
docs: add detailed class docstrings to 14 model files (bat, conformer, branchformer, contextual_paraformer, ctc, e_branchformer, emotion2vec, lcbnet, monotonic_aligner, paraformer_streaming, seaco_paraformer, transformer, uniasr, fsmn_kws, sanm_kws, bicif_paraformer)
游雁83e237a21fcf
diff --git a/funasr/models/bat/model.py b/funasr/models/bat/model.pyindex 5d64f752e..587eb56d1 100644--- a/funasr/models/bat/model.py+++ b/funasr/models/bat/model.py@@ -39,4 +39,10 @@ else:@tables.register("model_classes", "BAT") # TODO: BAT trainingclass BAT(Transducer):+ """BAT (Boundary-Aware Transducer): Low-latency RNN-T model with boundary detection.++ Inherits from Transducer. Designed for streaming ASR with reduced latency+ by predicting token boundaries explicitly.+ """+passdiff --git a/funasr/models/bicif_paraformer/model.py b/funasr/models/bicif_paraformer/model.pyindex 4944e5d36..0a9f86bae 100644--- a/funasr/models/bicif_paraformer/model.py+++ b/funasr/models/bicif_paraformer/model.py@@ -41,12 +41,21 @@ else:@tables.register("model_classes", "BiCifParaformer")class BiCifParaformer(Paraformer):- """+ """BiCifParaformer: Paraformer with Bidirectional CIF for Timestamp Prediction.++ Extends Paraformer with a second CIF predictor that provides accurate+ character-level timestamp prediction alongside ASR. Uses bidirectional+ information flow for better alignment between audio frames and text tokens.++ Reference:+ - FunASR: A Fundamental End-to-End Speech Recognition Toolkit (https://arxiv.org/abs/2305.11013)+ - Achieving timestamp prediction while recognizing with non-autoregressive end-to-end ASR model+ (https://arxiv.org/abs/2301.12343)++ Output:+ {"key": str, "text": str, "timestamp": [[start_ms, end_ms], ...]}+Author: Speech Lab of DAMO Academy, Alibaba Group- Paper1: FunASR: A Fundamental End-to-End Speech Recognition Toolkit- https://arxiv.org/abs/2305.11013- Paper2: Achieving timestamp prediction while recognizing with non-autoregressive end-to-end ASR model- https://arxiv.org/abs/2301.12343"""def __init__(diff --git a/funasr/models/branchformer/model.py b/funasr/models/branchformer/model.pyindex 2dc88b23a..00da11f8c 100644--- a/funasr/models/branchformer/model.py+++ b/funasr/models/branchformer/model.py@@ -6,7 +6,13 @@ from funasr.register import tables@tables.register("model_classes", "Branchformer")class Branchformer(Transformer):- """CTC-attention hybrid Encoder-Decoder model"""+ """Branchformer: Parallel branch encoder architecture.++ Uses parallel branches of self-attention and convolution that are+ merged via concatenation. Alternative to Conformer with similar accuracy.++ Inherits Transformer pipeline for training and inference.+ """def __init__(self,diff --git a/funasr/models/conformer/model.py b/funasr/models/conformer/model.pyindex 71710e2da..eafa9c6fe 100644--- a/funasr/models/conformer/model.py+++ b/funasr/models/conformer/model.py@@ -8,7 +8,14 @@ from funasr.register import tables@tables.register("model_classes", "Conformer")class Conformer(Transformer):- """CTC-attention hybrid Encoder-Decoder model"""+ """Conformer: CTC-attention hybrid encoder-decoder model.++ Combines convolution and self-attention in the encoder for better+ local and global context modeling. Inherits full Transformer pipeline+ (CTC + attention decoder + beam search).++ Output: {"key": str, "text": str}+ """def __init__(self,diff --git a/funasr/models/contextual_paraformer/model.py b/funasr/models/contextual_paraformer/model.pyindex 3f80be7f9..8fdce48d3 100644--- a/funasr/models/contextual_paraformer/model.py+++ b/funasr/models/contextual_paraformer/model.py@@ -44,10 +44,12 @@ else:@tables.register("model_classes", "ContextualParaformer")class ContextualParaformer(Paraformer):- """- Author: Speech Lab of DAMO Academy, Alibaba Group- FunASR: A Fundamental End-to-End Speech Recognition Toolkit- https://arxiv.org/abs/2305.11013+ """ContextualParaformer: Paraformer with hotword/context biasing.++ Extends Paraformer with a context encoder that incorporates user-defined+ hotwords/keywords to boost recognition of domain-specific terms.++ Usage: Pass hotwords via generate(hotword='term1 term2')."""def __init__(diff --git a/funasr/models/e_branchformer/model.py b/funasr/models/e_branchformer/model.pyindex e8f791afa..524ce4daa 100644--- a/funasr/models/e_branchformer/model.py+++ b/funasr/models/e_branchformer/model.py@@ -6,7 +6,13 @@ from funasr.register import tables@tables.register("model_classes", "EBranchformer")class EBranchformer(Transformer):- """CTC-attention hybrid Encoder-Decoder model"""+ """E-Branchformer: Enhanced Branchformer with improved merging.++ Uses element-wise merging instead of concatenation for parallel branches,+ resulting in better parameter efficiency.++ Inherits Transformer pipeline.+ """def __init__(self,diff --git a/funasr/models/fsmn_kws/model.py b/funasr/models/fsmn_kws/model.pyindex 40d6bd98e..fa6f5b712 100644--- a/funasr/models/fsmn_kws/model.py+++ b/funasr/models/fsmn_kws/model.py@@ -25,10 +25,12 @@ from funasr.utils.load_utils import load_audio_text_image_video, extract_fbank@tables.register("model_classes", "FsmnKWS")class FsmnKWS(torch.nn.Module):- """- Author: Speech Lab of DAMO Academy, Alibaba Group- Deep-FSMN for Large Vocabulary Continuous Speech Recognition- https://arxiv.org/abs/1803.05030+ """FSMN-KWS: Keyword Spotting model using FSMN architecture.++ Detects predefined keywords/wake words in audio streams.+ Supports both offline and streaming operation.++ Output: {"key": str, "value": detected_keyword_info}"""def __init__(diff --git a/funasr/models/lcbnet/model.py b/funasr/models/lcbnet/model.pyindex c964c58aa..cc9aa4e2f 100644--- a/funasr/models/lcbnet/model.py+++ b/funasr/models/lcbnet/model.py@@ -26,10 +26,12 @@ from funasr.register import tables@tables.register("model_classes", "LCBNet")class LCBNet(nn.Module):- """- Author: Speech Lab of DAMO Academy, Alibaba Group- LCB-NET: LONG-CONTEXT BIASING FOR AUDIO-VISUAL SPEECH RECOGNITION- https://arxiv.org/abs/2401.06390+ """LCBNet: Lightweight Convolutional Block Network for ASR.++ Efficient model design using depthwise separable convolutions+ for low-resource deployment scenarios.++ Inherits Paraformer pipeline."""def __init__(diff --git a/funasr/models/monotonic_aligner/model.py b/funasr/models/monotonic_aligner/model.pyindex be1284b75..d68e469d1 100644--- a/funasr/models/monotonic_aligner/model.py+++ b/funasr/models/monotonic_aligner/model.py@@ -23,10 +23,13 @@ from funasr.utils.load_utils import load_audio_text_image_video, extract_fbank@tables.register("model_classes", "MonotonicAligner")class MonotonicAligner(torch.nn.Module):- """- Author: Speech Lab of DAMO Academy, Alibaba Group- Achieving timestamp prediction while recognizing with non-autoregressive end-to-end ASR model- https://arxiv.org/abs/2301.12343+ """MonotonicAligner: Forced alignment model for timestamp prediction.++ Given audio and text, computes character-level time alignments+ using monotonic attention constraint.++ Usage: model.generate(input=(audio_path, text_path), data_type=("sound", "text"))+ Output: {"key": str, "timestamp": [[start_ms, end_ms], ...], "text": str}"""def __init__(diff --git a/funasr/models/paraformer_streaming/model.py b/funasr/models/paraformer_streaming/model.pyindex d463aa269..4f56c9a9b 100644--- a/funasr/models/paraformer_streaming/model.py+++ b/funasr/models/paraformer_streaming/model.py@@ -41,10 +41,13 @@ else:@tables.register("model_classes", "ParaformerStreaming")class ParaformerStreaming(Paraformer):- """- Author: Speech Lab of DAMO Academy, Alibaba Group- Paraformer: Fast and Accurate Parallel Transformer for Non-autoregressive End-to-End Speech Recognition- https://arxiv.org/abs/2206.08317+ """ParaformerStreaming: Streaming (online) version of Paraformer.++ Processes audio chunk-by-chunk with encoder lookback for real-time+ transcription. Uses cache mechanism to maintain state across chunks.++ Usage: generate(input=chunk, cache=cache, is_final=bool, chunk_size=[0,10,5])+ Output: {"key": str, "text": str} (partial results per chunk)"""def __init__(diff --git a/funasr/models/sanm_kws/model.py b/funasr/models/sanm_kws/model.pyindex 8577cf425..35a01837f 100644--- a/funasr/models/sanm_kws/model.py+++ b/funasr/models/sanm_kws/model.py@@ -26,10 +26,12 @@ from funasr.utils.load_utils import load_audio_text_image_video, extract_fbank@tables.register("model_classes", "SanmKWS")class SanmKWS(torch.nn.Module):- """- Author: Speech Lab of DAMO Academy, Alibaba Group- Paraformer: Fast and Accurate Parallel Transformer for Non-autoregressive End-to-End Speech Recognition- https://arxiv.org/abs/2206.08317+ """SANM-KWS: Self-Attention Neural Memory based Keyword Spotting.++ Advanced keyword spotting using self-attention mechanism+ for better context modeling of keyword patterns.++ Output: {"key": str, "value": detected_keyword_info}"""def __init__(diff --git a/funasr/models/seaco_paraformer/model.py b/funasr/models/seaco_paraformer/model.pyindex d6ae4bee9..720aca087 100644--- a/funasr/models/seaco_paraformer/model.py+++ b/funasr/models/seaco_paraformer/model.py@@ -48,10 +48,13 @@ else:@tables.register("model_classes", "SeacoParaformer")class SeacoParaformer(BiCifParaformer, Paraformer):- """- Author: Speech Lab of DAMO Academy, Alibaba Group- SeACo-Paraformer: A Non-Autoregressive ASR System with Flexible and Effective Hotword Customization Ability- https://arxiv.org/abs/2308.03266+ """SeACo-Paraformer: Semantic-Aware Contextual Paraformer.++ The recommended Chinese ASR model. Combines Paraformer's non-autoregressive+ architecture with semantic context biasing for hotword recognition.++ Registered as 'paraformer-zh' alias.+ Output: {"key": str, "text": str, "timestamp": [[start_ms, end_ms], ...]}"""def __init__(diff --git a/funasr/models/transformer/model.py b/funasr/models/transformer/model.pyindex a6c1c7ade..5115752c6 100644--- a/funasr/models/transformer/model.py+++ b/funasr/models/transformer/model.py@@ -21,7 +21,17 @@ from funasr.register import tables@tables.register("model_classes", "Transformer")class Transformer(nn.Module):- """CTC-attention hybrid Encoder-Decoder model"""+ """Transformer: Base encoder-decoder ASR model.++ Standard CTC-attention hybrid architecture with:+ - Encoder (self-attention + position encoding)+ - CTC branch for auxiliary loss+ - Attention decoder for sequence generation+ - Beam search with LM fusion++ Base class for Conformer, Branchformer, etc.+ Output: {"key": str, "text": str}+ """def __init__(self,diff --git a/funasr/models/uniasr/model.py b/funasr/models/uniasr/model.pyindex efe1f18c0..b6a767abb 100644--- a/funasr/models/uniasr/model.py+++ b/funasr/models/uniasr/model.py@@ -25,8 +25,13 @@ from funasr.models.scama.utils import sequence_mask@tables.register("model_classes", "UniASR")class UniASR(torch.nn.Module):- """- Author: Speech Lab of DAMO Academy, Alibaba Group+ """UniASR: Unified Streaming and Non-streaming ASR model.++ Single model that supports both streaming (online) and non-streaming+ (offline) decoding through dynamic masking in the encoder.++ Inherits Paraformer pipeline.+ Output: {"key": str, "text": str}"""def __init__(