This commit is contained in:
LauraGPT
2026-10-01 16:41:38 +00:00
parent 785723c945
commit 478afd4018
+66 -56
View File
@@ -963,8 +963,11 @@
except ImportError:
return False
</code></pre></details></div>
<div class="api-detail" id="e2" tabindex="-1"><span class="dtag badge-f">function</span><h2><code>prepare_data_iterator(data_in, input_len=None, data_type=None, key=None)</code></h2><div class="dmod">funasr.auto.auto_model · <a href="https://github.com/modelscope/FunASR/blob/main/funasr/auto/auto_model.py#L451" rel="noopener noreferrer" target="_blank">View on GitHub ↗</a></div><div class="ddoc"><p class="muted">No documentation yet.</p></div><details class="src-block"><summary>Source code</summary><pre><code>def prepare_data_iterator(data_in, input_len=None, data_type=None, key=None):
""" """
<div class="api-detail" id="e2" tabindex="-1"><span class="dtag badge-f">function</span><h2><code>prepare_data_iterator(data_in, input_len=None, data_type=None, key=None, input_format="auto")</code></h2><div class="dmod">funasr.auto.auto_model · <a href="https://github.com/modelscope/FunASR/blob/main/funasr/auto/auto_model.py#L451" rel="noopener noreferrer" target="_blank">View on GitHub ↗</a></div><div class="ddoc"><p>Prepare inputs, optionally interpreting audio bytes as explicit PCM16.</p>
</div><details class="src-block"><summary>Source code</summary><pre><code>def prepare_data_iterator(
data_in, input_len=None, data_type=None, key=None, input_format="auto"
):
"""Prepare inputs, optionally interpreting audio bytes as explicit PCM16."""
data_list = []
key_list = []
filelist = [".scp", ".txt", ".json", ".jsonl", ".text"]
@@ -991,10 +994,8 @@
lines = line.strip().split(maxsplit=1)
data = lines[1] if len(lines) &gt; 1 else lines[0]
key = lines[0] if len(lines) &gt; 1 else key
data_list.append(data)
</code></pre><a class="src-more" href="https://github.com/modelscope/FunASR/blob/main/funasr/auto/auto_model.py#L451" rel="noopener noreferrer" target="_blank">View full source on GitHub →</a></details></div>
<div class="api-detail" id="e3" tabindex="-1"><span class="dtag badge-c">class</span><h2><code>AutoModel(**kwargs)</code></h2><div class="dmod">funasr.auto.auto_model · <a href="https://github.com/modelscope/FunASR/blob/main/funasr/auto/auto_model.py#L522" rel="noopener noreferrer" target="_blank">View on GitHub ↗</a></div><div class="ddoc"><p class="muted">No documentation yet.</p></div><details class="src-block"><summary>Source code</summary><pre><code>class AutoModel:
<div class="api-detail" id="e3" tabindex="-1"><span class="dtag badge-c">class</span><h2><code>AutoModel(**kwargs)</code></h2><div class="dmod">funasr.auto.auto_model · <a href="https://github.com/modelscope/FunASR/blob/main/funasr/auto/auto_model.py#L530" rel="noopener noreferrer" target="_blank">View on GitHub ↗</a></div><div class="ddoc"><p class="muted">No documentation yet.</p></div><details class="src-block"><summary>Source code</summary><pre><code>class AutoModel:
def __init__(self, **kwargs):
"""Initialize AutoModel with ASR model and optional sub-models.
@@ -1024,7 +1025,7 @@
Examples:
&gt;&gt;&gt; model = AutoModel(model="paraformer-zh", vad_model="fsmn-vad", punc_model="ct-punc")
&gt;&gt;&gt; model = AutoModel(model="FunAudioLLM/Fun-ASR-Nano-2512", trust_remote_code=True,
</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>
</code></pre><a class="src-more" href="https://github.com/modelscope/FunASR/blob/main/funasr/auto/auto_model.py#L530" 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#L532">L532</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>
@@ -1052,7 +1053,7 @@
<p>&gt;&gt;&gt; model = AutoModel(model="paraformer-zh", vad_model="fsmn-vad", punc_model="ct-punc")</p>
<p>&gt;&gt;&gt; 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#L634" rel="noopener noreferrer" target="_blank">L634</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#L642" rel="noopener noreferrer" target="_blank">L642</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>
@@ -1097,7 +1098,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#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>
</code></pre><a class="src-more" href="https://github.com/modelscope/FunASR/blob/main/funasr/auto/auto_model.py#L642" 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#L824" rel="noopener noreferrer" target="_blank">L824</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>
@@ -1117,6 +1118,9 @@
<li>device: Placement is selected at construction. Runtime device overrides</li>
<li class="sub">are ignored; create another AutoModel to use a different device.</li>
<li>cache (dict): State cache for streaming mode. Pass {} for first call.</li>
<li>input_format (str): "auto" (default) or "pcm_s16le" to bypass</li>
<li class="sub">container detection for mono little-endian PCM16 byte inputs.</li>
<li class="sub">Use fs for the source sample rate.</li>
<li>hotword (str/list): Keywords to boost recognition accuracy.</li>
<li>postprocess_hotwords (str/list/dict): Text-level hotword correction after</li>
<li class="sub">decoding. Unlike model-level ``hotword``, this runs on the final text.</li>
@@ -1159,6 +1163,9 @@
- device: Placement is selected at construction. Runtime device overrides
are ignored; create another AutoModel to use a different device.
- cache (dict): State cache for streaming mode. Pass {} for first call.
- input_format (str): "auto" (default) or "pcm_s16le" to bypass
container detection for mono little-endian PCM16 byte inputs.
Use fs for the source sample rate.
- hotword (str/list): Keywords to boost recognition accuracy.
- postprocess_hotwords (str/list/dict): Text-level hotword correction after
decoding. Unlike model-level ``hotword``, this runs on the final text.
@@ -1166,10 +1173,7 @@
word or an explicit mapping like ``错误词=&gt;目标词``.
- postprocess_hotword_threshold (float): Fuzzy match threshold in [0, 1].
- return_postprocess_hotword_matches (bool): Include replacement details.
- 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#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>
</code></pre><a class="src-more" href="https://github.com/modelscope/FunASR/blob/main/funasr/auto/auto_model.py#L824" 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#L889" rel="noopener noreferrer" target="_blank">L889</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>
@@ -1214,7 +1218,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#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>
</code></pre><a class="src-more" href="https://github.com/modelscope/FunASR/blob/main/funasr/auto/auto_model.py#L889" 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#L992" rel="noopener noreferrer" target="_blank">L992</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>
@@ -1254,12 +1258,12 @@
kwargs = self.kwargs
# step.1: compute the vad model
beg_vad = time.time()
res = self.inference(
input, input_len=input_len, model=self.vad_model, kwargs=self.vad_kwargs, **cfg
)
end_vad = time.time()
</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>
vad_cfg = {
"input_format": kwargs.get("input_format", "auto"),
"fs": kwargs.get("fs", 16000),
**cfg,
}
</code></pre><a class="src-more" href="https://github.com/modelscope/FunASR/blob/main/funasr/auto/auto_model.py#L992" 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#L1407" rel="noopener noreferrer" target="_blank">L1407</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>
@@ -1304,8 +1308,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#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>
</code></pre><a class="src-more" href="https://github.com/modelscope/FunASR/blob/main/funasr/auto/auto_model.py#L1407" 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#L642" 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>
@@ -1350,8 +1354,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#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>
</code></pre><a class="src-more" href="https://github.com/modelscope/FunASR/blob/main/funasr/auto/auto_model.py#L642" 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#L824" 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>
@@ -1371,6 +1375,9 @@
<li>device: Placement is selected at construction. Runtime device overrides</li>
<li class="sub">are ignored; create another AutoModel to use a different device.</li>
<li>cache (dict): State cache for streaming mode. Pass {} for first call.</li>
<li>input_format (str): "auto" (default) or "pcm_s16le" to bypass</li>
<li class="sub">container detection for mono little-endian PCM16 byte inputs.</li>
<li class="sub">Use fs for the source sample rate.</li>
<li>hotword (str/list): Keywords to boost recognition accuracy.</li>
<li>postprocess_hotwords (str/list/dict): Text-level hotword correction after</li>
<li class="sub">decoding. Unlike model-level ``hotword``, this runs on the final text.</li>
@@ -1413,6 +1420,9 @@
- device: Placement is selected at construction. Runtime device overrides
are ignored; create another AutoModel to use a different device.
- cache (dict): State cache for streaming mode. Pass {} for first call.
- input_format (str): "auto" (default) or "pcm_s16le" to bypass
container detection for mono little-endian PCM16 byte inputs.
Use fs for the source sample rate.
- hotword (str/list): Keywords to boost recognition accuracy.
- postprocess_hotwords (str/list/dict): Text-level hotword correction after
decoding. Unlike model-level ``hotword``, this runs on the final text.
@@ -1420,11 +1430,8 @@
word or an explicit mapping like ``错误词=&gt;目标词``.
- postprocess_hotword_threshold (float): Fuzzy match threshold in [0, 1].
- return_postprocess_hotword_matches (bool): Include replacement details.
- 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#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>
</code></pre><a class="src-more" href="https://github.com/modelscope/FunASR/blob/main/funasr/auto/auto_model.py#L824" 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#L889" 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>
@@ -1469,8 +1476,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#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>
</code></pre><a class="src-more" href="https://github.com/modelscope/FunASR/blob/main/funasr/auto/auto_model.py#L889" 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#L992" 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>
@@ -1510,13 +1517,13 @@
kwargs = self.kwargs
# step.1: compute the vad model
beg_vad = time.time()
res = self.inference(
input, input_len=input_len, model=self.vad_model, kwargs=self.vad_kwargs, **cfg
)
end_vad = time.time()
</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>
vad_cfg = {
"input_format": kwargs.get("input_format", "auto"),
"fs": kwargs.get("fs", 16000),
**cfg,
}
</code></pre><a class="src-more" href="https://github.com/modelscope/FunASR/blob/main/funasr/auto/auto_model.py#L992" 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#L1407" 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>
@@ -1561,7 +1568,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#L1387" 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#L1407" 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) -&gt; 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>
@@ -22350,24 +22357,37 @@
):
data_or_path_or_list_j = load_audio_text_image_video(
</code></pre><a class="src-more" href="https://github.com/modelscope/FunASR/blob/main/funasr/utils/load_utils.py#L51" rel="noopener noreferrer" target="_blank">View full source on GitHub →</a></details></div>
<div class="api-detail" id="e390" tabindex="-1"><span class="dtag badge-f">function</span><h2><code>load_bytes(input)</code></h2><div class="dmod">funasr.utils.load_utils · <a href="https://github.com/modelscope/FunASR/blob/main/funasr/utils/load_utils.py#L315" rel="noopener noreferrer" target="_blank">View on GitHub ↗</a></div><div class="ddoc"><p>Convert raw PCM or container-formatted audio bytes to a waveform.</p>
<div class="api-detail" id="e390" tabindex="-1"><span class="dtag badge-f">function</span><h2><code>load_bytes(input, input_format="auto")</code></h2><div class="dmod">funasr.utils.load_utils · <a href="https://github.com/modelscope/FunASR/blob/main/funasr/utils/load_utils.py#L315" rel="noopener noreferrer" target="_blank">View on GitHub ↗</a></div><div class="ddoc"><p>Convert raw PCM or container-formatted audio bytes to a waveform.</p>
<h4>Args:</h4>
<ul>
<li><code>input (bytes)</code> — Raw int16 PCM or encoded audio-file bytes.</li>
<li><code>input_format (str)</code> — "auto" preserves format detection. "pcm_s16le"</li>
<li class="sub">reads mono signed little-endian PCM16 without probing or decoding.</li>
</ul>
<h4>Returns:</h4>
<ul>
<li><code>numpy.ndarray</code> — Mono float32 samples at 16 kHz.</li>
<li><code>numpy.ndarray</code> — Normalized float32 samples. Containers are resampled to</li>
</ul>
</div><details class="src-block"><summary>Source code</summary><pre><code>def load_bytes(input):
<p>16 kHz; raw PCM keeps its source rate and is not resampled here.</p>
</div><details class="src-block"><summary>Source code</summary><pre><code>def load_bytes(input, input_format="auto"):
"""Convert raw PCM or container-formatted audio bytes to a waveform.
Args:
input (bytes): Raw int16 PCM or encoded audio-file bytes.
input_format (str): "auto" preserves format detection. "pcm_s16le"
reads mono signed little-endian PCM16 without probing or decoding.
Returns:
numpy.ndarray: Mono float32 samples at 16 kHz.
numpy.ndarray: Normalized float32 samples. Containers are resampled to
16 kHz; raw PCM keeps its source rate and is not resampled here.
"""
if input_format not in ("auto", "pcm_s16le"):
raise ValueError("input_format must be 'auto' or 'pcm_s16le'")
if input_format == "pcm_s16le":
if len(input) % 2:
raise ValueError("PCM16 input must contain complete 2-byte samples")
return np.frombuffer(input, dtype="&lt;i2").astype(np.float32) / 32768.0
if _is_audio_container(input):
try:
waveform = load_audio_text_image_video(BytesIO(input), fs=16000)
@@ -22379,18 +22399,8 @@
) from exc
else:
if isinstance(waveform, torch.Tensor):
waveform = waveform.detach().cpu().numpy()
return np.asarray(waveform, dtype=np.float32)
middle_data = np.frombuffer(input, dtype=np.int16)
middle_data = np.asarray(middle_data)
if middle_data.dtype.kind not in "iu":
raise TypeError("'middle_data' must be an array of integers")
dtype = np.dtype("float32")
if dtype.kind != "f":
raise TypeError("'dtype' must be a floating point type")
</code></pre><a class="src-more" href="https://github.com/modelscope/FunASR/blob/main/funasr/utils/load_utils.py#L315" rel="noopener noreferrer" target="_blank">View full source on GitHub →</a></details></div>
<div class="api-detail" id="e391" tabindex="-1"><span class="dtag badge-f">function</span><h2><code>validate_frame_rate(input, fs: int = 16000)</code></h2><div class="dmod">funasr.utils.load_utils · <a href="https://github.com/modelscope/FunASR/blob/main/funasr/utils/load_utils.py#L353" rel="noopener noreferrer" target="_blank">View on GitHub ↗</a></div><div class="ddoc"><p>Validate frame rate.</p>
<div class="api-detail" id="e391" tabindex="-1"><span class="dtag badge-f">function</span><h2><code>validate_frame_rate(input, fs: int = 16000)</code></h2><div class="dmod">funasr.utils.load_utils · <a href="https://github.com/modelscope/FunASR/blob/main/funasr/utils/load_utils.py#L363" rel="noopener noreferrer" target="_blank">View on GitHub ↗</a></div><div class="ddoc"><p>Validate frame rate.</p>
<h4>Args:</h4>
<ul>
<li><code>input</code> — Input audio/text data.</li>
@@ -22426,8 +22436,8 @@
output = BytesIO()
audio.export(output, format="wav")
output.seek(0)
</code></pre><a class="src-more" href="https://github.com/modelscope/FunASR/blob/main/funasr/utils/load_utils.py#L353" rel="noopener noreferrer" target="_blank">View full source on GitHub →</a></details></div>
<div class="api-detail" id="e392" tabindex="-1"><span class="dtag badge-f">function</span><h2><code>extract_fbank(data, data_len=None, data_type: str = "sound", frontend=None, **kwargs)</code></h2><div class="dmod">funasr.utils.load_utils · <a href="https://github.com/modelscope/FunASR/blob/main/funasr/utils/load_utils.py#L390" rel="noopener noreferrer" target="_blank">View on GitHub ↗</a></div><div class="ddoc"><p>Extract filter-bank features from audio data.</p>
</code></pre><a class="src-more" href="https://github.com/modelscope/FunASR/blob/main/funasr/utils/load_utils.py#L363" rel="noopener noreferrer" target="_blank">View full source on GitHub →</a></details></div>
<div class="api-detail" id="e392" tabindex="-1"><span class="dtag badge-f">function</span><h2><code>extract_fbank(data, data_len=None, data_type: str = "sound", frontend=None, **kwargs)</code></h2><div class="dmod">funasr.utils.load_utils · <a href="https://github.com/modelscope/FunASR/blob/main/funasr/utils/load_utils.py#L400" rel="noopener noreferrer" target="_blank">View on GitHub ↗</a></div><div class="ddoc"><p>Extract filter-bank features from audio data.</p>
<h4>Args:</h4>
<ul>
<li><code>data</code> — Audio samples (list of numpy arrays or tensors).</li>
@@ -22469,7 +22479,7 @@
for data_i in data:
if isinstance(data_i, np.ndarray):
data_i = torch.from_numpy(data_i)
</code></pre><a class="src-more" href="https://github.com/modelscope/FunASR/blob/main/funasr/utils/load_utils.py#L390" 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/utils/load_utils.py#L400" rel="noopener noreferrer" target="_blank">View full source on GitHub →</a></details></div>
<div class="api-detail" id="e393" tabindex="-1"><span class="dtag badge-f">function</span><h2><code>statistic_model_parameters(model, prefix=None)</code></h2><div class="dmod">funasr.utils.misc · <a href="https://github.com/modelscope/FunASR/blob/main/funasr/utils/misc.py#L10" rel="noopener noreferrer" target="_blank">View on GitHub ↗</a></div><div class="ddoc"><p>Statistic model parameters.</p>
<h4>Args:</h4>
<ul>