mirror of
https://github.com/modelscope/FunASR.git
synced 2026-10-12 02:19:18 +00:00
deploy: 7b098acefc
This commit is contained in:
@@ -1002,7 +1002,8 @@
|
||||
Args:
|
||||
model (str): Model name (hub alias or full ID) or local path.
|
||||
device (str): Device for inference. "cuda:0", "cpu", "mps", "npu:0".
|
||||
Falls back to CPU if specified device is unavailable.
|
||||
Logs a warning and falls back to CPU if unavailable (default: "cuda").
|
||||
Explicit CPU use or ngpu=0 does not emit a fallback warning.
|
||||
vad_model (str, optional): VAD model for long audio segmentation.
|
||||
Enables processing of any-length audio.
|
||||
vad_kwargs (dict, optional): VAD config, e.g. {"device": "cpu"}.
|
||||
@@ -1023,13 +1024,13 @@
|
||||
Examples:
|
||||
>>> model = AutoModel(model="paraformer-zh", vad_model="fsmn-vad", punc_model="ct-punc")
|
||||
>>> model = AutoModel(model="FunAudioLLM/Fun-ASR-Nano-2512", trust_remote_code=True,
|
||||
... remote_code="./model.py", vad_model="fsmn-vad", spk_model="cam++", hub="hf")
|
||||
</code></pre><a class="src-more" href="https://github.com/modelscope/FunASR/blob/main/funasr/auto/auto_model.py#L522" rel="noopener noreferrer" target="_blank">View full source on GitHub →</a></details><h3 class="mt">Constructor</h3><div class="mblk"><a class="gh-link" href="https://github.com/modelscope/FunASR/blob/main/funasr/auto/auto_model.py#L524">L524</a><p>Initialize AutoModel with ASR model and optional sub-models.</p>
|
||||
<h4>Args:</h4>
|
||||
<ul>
|
||||
<li><code>model (str)</code> — Model name (hub alias or full ID) or local path.</li>
|
||||
<li><code>device (str)</code> — Device for inference. "cuda:0", "cpu", "mps", "npu:0".</li>
|
||||
<li class="sub">Falls back to CPU if specified device is unavailable.</li>
|
||||
<li class="sub">Logs a warning and falls back to CPU if unavailable (default: "cuda").</li>
|
||||
<li class="sub">Explicit CPU use or ngpu=0 does not emit a fallback warning.</li>
|
||||
<li><code>vad_model (str, optional)</code> — VAD model for long audio segmentation.</li>
|
||||
<li class="sub">Enables processing of any-length audio.</li>
|
||||
<li><code>vad_kwargs (dict, optional)</code> — VAD config, e.g. {"device": "cpu"}.</li>
|
||||
@@ -1051,7 +1052,7 @@
|
||||
<p>>>> model = AutoModel(model="paraformer-zh", vad_model="fsmn-vad", punc_model="ct-punc")</p>
|
||||
<p>>>> model = AutoModel(model="FunAudioLLM/Fun-ASR-Nano-2512", trust_remote_code=True,</p>
|
||||
<p>... remote_code="./model.py", vad_model="fsmn-vad", spk_model="cam++", hub="hf")</p>
|
||||
</div><h3 class="mt">Methods</h3><div class="mblk"><code>.build_model(**kwargs)</code> <a class="gh-link" href="https://github.com/modelscope/FunASR/blob/main/funasr/auto/auto_model.py#L633" rel="noopener noreferrer" target="_blank">L633</a><div class="mdoc"><p>Download model from hub, build all components, and load pretrained weights.</p>
|
||||
</div><h3 class="mt">Methods</h3><div class="mblk"><code>.build_model(**kwargs)</code> <a class="gh-link" href="https://github.com/modelscope/FunASR/blob/main/funasr/auto/auto_model.py#L634" rel="noopener noreferrer" target="_blank">L634</a><div class="mdoc"><p>Download model from hub, build all components, and load pretrained weights.</p>
|
||||
<p>This method handles the full model construction pipeline:</p>
|
||||
<p>1. Download model files from ModelScope/HuggingFace (if not local)</p>
|
||||
<p>2. Parse config.yaml to determine model class, tokenizer, frontend</p>
|
||||
@@ -1096,7 +1097,7 @@
|
||||
kwargs.setdefault("model_conf", {})
|
||||
kwargs.setdefault("model_path", kwargs["model"])
|
||||
if "model_conf" not in kwargs:
|
||||
</code></pre><a class="src-more" href="https://github.com/modelscope/FunASR/blob/main/funasr/auto/auto_model.py#L633" rel="noopener noreferrer" target="_blank">View full source →</a></details></div><div class="mblk"><code>.generate(input, input_len=None, progress_callback=None, **cfg)</code> <a class="gh-link" href="https://github.com/modelscope/FunASR/blob/main/funasr/auto/auto_model.py#L807" rel="noopener noreferrer" target="_blank">L807</a><div class="mdoc"><p>Run speech recognition on input audio.</p>
|
||||
</code></pre><a class="src-more" href="https://github.com/modelscope/FunASR/blob/main/funasr/auto/auto_model.py#L634" rel="noopener noreferrer" target="_blank">View full source →</a></details></div><div class="mblk"><code>.generate(input, input_len=None, progress_callback=None, **cfg)</code> <a class="gh-link" href="https://github.com/modelscope/FunASR/blob/main/funasr/auto/auto_model.py#L816" rel="noopener noreferrer" target="_blank">L816</a><div class="mdoc"><p>Run speech recognition on input audio.</p>
|
||||
<p>This is the primary user-facing method. It automatically routes to:</p>
|
||||
<ul>
|
||||
<li>inference() if no vad_model is configured (single utterance)</li>
|
||||
@@ -1168,7 +1169,7 @@
|
||||
- language (str): Language hint ("auto", "zh", "en", "Chinese", etc.)
|
||||
- batch_size_s (int): Dynamic batch total duration in seconds.
|
||||
- is_final (bool): Last chunk flag for streaming mode.
|
||||
</code></pre><a class="src-more" href="https://github.com/modelscope/FunASR/blob/main/funasr/auto/auto_model.py#L807" rel="noopener noreferrer" target="_blank">View full source →</a></details></div><div class="mblk"><code>.inference(input, input_len=None, model=None, kwargs=None, key=None, progress_callback=None, **cfg)</code> <a class="gh-link" href="https://github.com/modelscope/FunASR/blob/main/funasr/auto/auto_model.py#L869" rel="noopener noreferrer" target="_blank">L869</a><div class="mdoc"><p>Run model inference on input data (internal method).</p>
|
||||
</code></pre><a class="src-more" href="https://github.com/modelscope/FunASR/blob/main/funasr/auto/auto_model.py#L816" rel="noopener noreferrer" target="_blank">View full source →</a></details></div><div class="mblk"><code>.inference(input, input_len=None, model=None, kwargs=None, key=None, progress_callback=None, **cfg)</code> <a class="gh-link" href="https://github.com/modelscope/FunASR/blob/main/funasr/auto/auto_model.py#L878" rel="noopener noreferrer" target="_blank">L878</a><div class="mdoc"><p>Run model inference on input data (internal method).</p>
|
||||
<p>Handles batching, timing, and progress reporting. Called by generate()</p>
|
||||
<p>and inference_with_vad(). Typically not called directly by users.</p>
|
||||
<h4>Args:</h4>
|
||||
@@ -1213,7 +1214,7 @@
|
||||
if kwargs is None:
|
||||
self._reset_runtime_configs()
|
||||
kwargs = self.kwargs if kwargs is None else kwargs
|
||||
</code></pre><a class="src-more" href="https://github.com/modelscope/FunASR/blob/main/funasr/auto/auto_model.py#L869" rel="noopener noreferrer" target="_blank">View full source →</a></details></div><div class="mblk"><code>.inference_with_vad(input, input_len=None, **cfg)</code> <a class="gh-link" href="https://github.com/modelscope/FunASR/blob/main/funasr/auto/auto_model.py#L971" rel="noopener noreferrer" target="_blank">L971</a><div class="mdoc"><p>Run ASR with VAD segmentation, punctuation, and optional speaker diarization.</p>
|
||||
</code></pre><a class="src-more" href="https://github.com/modelscope/FunASR/blob/main/funasr/auto/auto_model.py#L878" rel="noopener noreferrer" target="_blank">View full source →</a></details></div><div class="mblk"><code>.inference_with_vad(input, input_len=None, **cfg)</code> <a class="gh-link" href="https://github.com/modelscope/FunASR/blob/main/funasr/auto/auto_model.py#L980" rel="noopener noreferrer" target="_blank">L980</a><div class="mdoc"><p>Run ASR with VAD segmentation, punctuation, and optional speaker diarization.</p>
|
||||
<p>Pipeline:</p>
|
||||
<p>1. VAD: Segment audio into speech regions</p>
|
||||
<p>2. ASR: Recognize each segment (sorted by length for efficient batching)</p>
|
||||
@@ -1258,7 +1259,7 @@
|
||||
)
|
||||
end_vad = time.time()
|
||||
|
||||
</code></pre><a class="src-more" href="https://github.com/modelscope/FunASR/blob/main/funasr/auto/auto_model.py#L971" rel="noopener noreferrer" target="_blank">View full source →</a></details></div><div class="mblk"><code>.export(input=None, **cfg)</code> <a class="gh-link" href="https://github.com/modelscope/FunASR/blob/main/funasr/auto/auto_model.py#L1378" rel="noopener noreferrer" target="_blank">L1378</a><div class="mdoc"><p>Export model to ONNX format.</p>
|
||||
</code></pre><a class="src-more" href="https://github.com/modelscope/FunASR/blob/main/funasr/auto/auto_model.py#L980" rel="noopener noreferrer" target="_blank">View full source →</a></details></div><div class="mblk"><code>.export(input=None, **cfg)</code> <a class="gh-link" href="https://github.com/modelscope/FunASR/blob/main/funasr/auto/auto_model.py#L1387" rel="noopener noreferrer" target="_blank">L1387</a><div class="mdoc"><p>Export model to ONNX format.</p>
|
||||
<p>Creates a deep copy of the model to isolate ONNX operator monkey-patching,</p>
|
||||
<p>then runs torch.onnx.export. The original model remains usable after export.</p>
|
||||
<h4>Args:</h4>
|
||||
@@ -1303,8 +1304,8 @@
|
||||
|
||||
device = cfg.get("device", "cpu")
|
||||
|
||||
</code></pre><a class="src-more" href="https://github.com/modelscope/FunASR/blob/main/funasr/auto/auto_model.py#L1378" rel="noopener noreferrer" target="_blank">View full source →</a></details></div></div>
|
||||
<div class="api-detail" id="e4" tabindex="-1"><span class="dtag badge-m">method</span><h2><code>AutoModel.build_model(**kwargs)</code></h2><div class="dmod">funasr.auto.auto_model.AutoModel · <a href="https://github.com/modelscope/FunASR/blob/main/funasr/auto/auto_model.py#L633" rel="noopener noreferrer" target="_blank">View on GitHub ↗</a></div><div class="ddoc"><p>Download model from hub, build all components, and load pretrained weights.</p>
|
||||
</code></pre><a class="src-more" href="https://github.com/modelscope/FunASR/blob/main/funasr/auto/auto_model.py#L1387" rel="noopener noreferrer" target="_blank">View full source →</a></details></div></div>
|
||||
<div class="api-detail" id="e4" tabindex="-1"><span class="dtag badge-m">method</span><h2><code>AutoModel.build_model(**kwargs)</code></h2><div class="dmod">funasr.auto.auto_model.AutoModel · <a href="https://github.com/modelscope/FunASR/blob/main/funasr/auto/auto_model.py#L634" rel="noopener noreferrer" target="_blank">View on GitHub ↗</a></div><div class="ddoc"><p>Download model from hub, build all components, and load pretrained weights.</p>
|
||||
<p>This method handles the full model construction pipeline:</p>
|
||||
<p>1. Download model files from ModelScope/HuggingFace (if not local)</p>
|
||||
<p>2. Parse config.yaml to determine model class, tokenizer, frontend</p>
|
||||
@@ -1349,8 +1350,8 @@
|
||||
kwargs.setdefault("model_conf", {})
|
||||
kwargs.setdefault("model_path", kwargs["model"])
|
||||
if "model_conf" not in kwargs:
|
||||
</code></pre><a class="src-more" href="https://github.com/modelscope/FunASR/blob/main/funasr/auto/auto_model.py#L633" rel="noopener noreferrer" target="_blank">View full source on GitHub →</a></details></div>
|
||||
<div class="api-detail" id="e5" tabindex="-1"><span class="dtag badge-m">method</span><h2><code>AutoModel.generate(input, input_len=None, progress_callback=None, **cfg)</code></h2><div class="dmod">funasr.auto.auto_model.AutoModel · <a href="https://github.com/modelscope/FunASR/blob/main/funasr/auto/auto_model.py#L807" rel="noopener noreferrer" target="_blank">View on GitHub ↗</a></div><div class="ddoc"><p>Run speech recognition on input audio.</p>
|
||||
</code></pre><a class="src-more" href="https://github.com/modelscope/FunASR/blob/main/funasr/auto/auto_model.py#L634" rel="noopener noreferrer" target="_blank">View full source on GitHub →</a></details></div>
|
||||
<div class="api-detail" id="e5" tabindex="-1"><span class="dtag badge-m">method</span><h2><code>AutoModel.generate(input, input_len=None, progress_callback=None, **cfg)</code></h2><div class="dmod">funasr.auto.auto_model.AutoModel · <a href="https://github.com/modelscope/FunASR/blob/main/funasr/auto/auto_model.py#L816" rel="noopener noreferrer" target="_blank">View on GitHub ↗</a></div><div class="ddoc"><p>Run speech recognition on input audio.</p>
|
||||
<p>This is the primary user-facing method. It automatically routes to:</p>
|
||||
<ul>
|
||||
<li>inference() if no vad_model is configured (single utterance)</li>
|
||||
@@ -1422,8 +1423,8 @@
|
||||
- language (str): Language hint ("auto", "zh", "en", "Chinese", etc.)
|
||||
- batch_size_s (int): Dynamic batch total duration in seconds.
|
||||
- is_final (bool): Last chunk flag for streaming mode.
|
||||
</code></pre><a class="src-more" href="https://github.com/modelscope/FunASR/blob/main/funasr/auto/auto_model.py#L807" rel="noopener noreferrer" target="_blank">View full source on GitHub →</a></details></div>
|
||||
<div class="api-detail" id="e6" tabindex="-1"><span class="dtag badge-m">method</span><h2><code>AutoModel.inference(input, input_len=None, model=None, kwargs=None, key=None, progress_callback=None, **cfg)</code></h2><div class="dmod">funasr.auto.auto_model.AutoModel · <a href="https://github.com/modelscope/FunASR/blob/main/funasr/auto/auto_model.py#L869" rel="noopener noreferrer" target="_blank">View on GitHub ↗</a></div><div class="ddoc"><p>Run model inference on input data (internal method).</p>
|
||||
</code></pre><a class="src-more" href="https://github.com/modelscope/FunASR/blob/main/funasr/auto/auto_model.py#L816" rel="noopener noreferrer" target="_blank">View full source on GitHub →</a></details></div>
|
||||
<div class="api-detail" id="e6" tabindex="-1"><span class="dtag badge-m">method</span><h2><code>AutoModel.inference(input, input_len=None, model=None, kwargs=None, key=None, progress_callback=None, **cfg)</code></h2><div class="dmod">funasr.auto.auto_model.AutoModel · <a href="https://github.com/modelscope/FunASR/blob/main/funasr/auto/auto_model.py#L878" rel="noopener noreferrer" target="_blank">View on GitHub ↗</a></div><div class="ddoc"><p>Run model inference on input data (internal method).</p>
|
||||
<p>Handles batching, timing, and progress reporting. Called by generate()</p>
|
||||
<p>and inference_with_vad(). Typically not called directly by users.</p>
|
||||
<h4>Args:</h4>
|
||||
@@ -1468,8 +1469,8 @@
|
||||
if kwargs is None:
|
||||
self._reset_runtime_configs()
|
||||
kwargs = self.kwargs if kwargs is None else kwargs
|
||||
</code></pre><a class="src-more" href="https://github.com/modelscope/FunASR/blob/main/funasr/auto/auto_model.py#L869" rel="noopener noreferrer" target="_blank">View full source on GitHub →</a></details></div>
|
||||
<div class="api-detail" id="e7" tabindex="-1"><span class="dtag badge-m">method</span><h2><code>AutoModel.inference_with_vad(input, input_len=None, **cfg)</code></h2><div class="dmod">funasr.auto.auto_model.AutoModel · <a href="https://github.com/modelscope/FunASR/blob/main/funasr/auto/auto_model.py#L971" rel="noopener noreferrer" target="_blank">View on GitHub ↗</a></div><div class="ddoc"><p>Run ASR with VAD segmentation, punctuation, and optional speaker diarization.</p>
|
||||
</code></pre><a class="src-more" href="https://github.com/modelscope/FunASR/blob/main/funasr/auto/auto_model.py#L878" rel="noopener noreferrer" target="_blank">View full source on GitHub →</a></details></div>
|
||||
<div class="api-detail" id="e7" tabindex="-1"><span class="dtag badge-m">method</span><h2><code>AutoModel.inference_with_vad(input, input_len=None, **cfg)</code></h2><div class="dmod">funasr.auto.auto_model.AutoModel · <a href="https://github.com/modelscope/FunASR/blob/main/funasr/auto/auto_model.py#L980" rel="noopener noreferrer" target="_blank">View on GitHub ↗</a></div><div class="ddoc"><p>Run ASR with VAD segmentation, punctuation, and optional speaker diarization.</p>
|
||||
<p>Pipeline:</p>
|
||||
<p>1. VAD: Segment audio into speech regions</p>
|
||||
<p>2. ASR: Recognize each segment (sorted by length for efficient batching)</p>
|
||||
@@ -1514,8 +1515,8 @@
|
||||
)
|
||||
end_vad = time.time()
|
||||
|
||||
</code></pre><a class="src-more" href="https://github.com/modelscope/FunASR/blob/main/funasr/auto/auto_model.py#L971" rel="noopener noreferrer" target="_blank">View full source on GitHub →</a></details></div>
|
||||
<div class="api-detail" id="e8" tabindex="-1"><span class="dtag badge-m">method</span><h2><code>AutoModel.export(input=None, **cfg)</code></h2><div class="dmod">funasr.auto.auto_model.AutoModel · <a href="https://github.com/modelscope/FunASR/blob/main/funasr/auto/auto_model.py#L1378" rel="noopener noreferrer" target="_blank">View on GitHub ↗</a></div><div class="ddoc"><p>Export model to ONNX format.</p>
|
||||
</code></pre><a class="src-more" href="https://github.com/modelscope/FunASR/blob/main/funasr/auto/auto_model.py#L980" rel="noopener noreferrer" target="_blank">View full source on GitHub →</a></details></div>
|
||||
<div class="api-detail" id="e8" tabindex="-1"><span class="dtag badge-m">method</span><h2><code>AutoModel.export(input=None, **cfg)</code></h2><div class="dmod">funasr.auto.auto_model.AutoModel · <a href="https://github.com/modelscope/FunASR/blob/main/funasr/auto/auto_model.py#L1387" rel="noopener noreferrer" target="_blank">View on GitHub ↗</a></div><div class="ddoc"><p>Export model to ONNX format.</p>
|
||||
<p>Creates a deep copy of the model to isolate ONNX operator monkey-patching,</p>
|
||||
<p>then runs torch.onnx.export. The original model remains usable after export.</p>
|
||||
<h4>Args:</h4>
|
||||
@@ -1560,7 +1561,7 @@
|
||||
|
||||
device = cfg.get("device", "cpu")
|
||||
|
||||
</code></pre><a class="src-more" href="https://github.com/modelscope/FunASR/blob/main/funasr/auto/auto_model.py#L1378" rel="noopener noreferrer" target="_blank">View full source on GitHub →</a></details></div>
|
||||
</code></pre><a class="src-more" href="https://github.com/modelscope/FunASR/blob/main/funasr/auto/auto_model.py#L1387" rel="noopener noreferrer" target="_blank">View full source on GitHub →</a></details></div>
|
||||
<div class="api-detail" id="e655" tabindex="-1"><span class="dtag badge-f">function</span><h2><code>check_vllm_applicable(model_name: str) -> bool</code></h2><div class="dmod">funasr.auto.auto_model_vllm · <a href="https://github.com/modelscope/FunASR/blob/main/funasr/auto/auto_model_vllm.py#L68" rel="noopener noreferrer" target="_blank">View on GitHub ↗</a></div><div class="ddoc"><p>Check if a model can use vLLM inference.</p>
|
||||
<h4>Args:</h4>
|
||||
<ul>
|
||||
|
||||
Reference in New Issue
Block a user