This commit is contained in:
LauraGPT
2026-09-09 17:33:15 +00:00
parent 1016e332f6
commit 1b1fff2caa
20 changed files with 322 additions and 366 deletions
+1 -1
View File
@@ -56,6 +56,7 @@
<details open="">
<summary>Get started</summary>
<nav aria-label="Get started">
<a href="https://www.funasr.com/en/docs/native-transformers.html">Transformers quickstart</a>
<a href="https://www.funasr.com/en/docs/installation.html">Installation &amp; environment checks</a>
<a href="https://www.funasr.com/en/docs/quickstart.html">Your first transcription</a>
<a href="https://www.funasr.com/en/docs/python-api.html">Python SDK: AutoModel</a>
@@ -67,7 +68,6 @@
<details open="">
<summary>Models &amp; capabilities</summary>
<nav aria-label="Models &amp; capabilities">
<a href="https://www.funasr.com/en/docs/native-transformers.html">Native Transformers Fun-ASR-Nano</a>
<a href="https://www.funasr.com/en/docs/moss-transcribe-diarize.html">MOSS transcription &amp; diarization</a>
<a href="https://www.funasr.com/en/docs/model-zoo.html">Model Zoo</a>
<a href="https://www.funasr.com/en/docs/streaming-vad.html">Streaming voice activity detection</a>
+1 -1
View File
@@ -56,6 +56,7 @@
<details open="">
<summary>Get started</summary>
<nav aria-label="Get started">
<a href="https://www.funasr.com/en/docs/native-transformers.html">Transformers quickstart</a>
<a href="https://www.funasr.com/en/docs/installation.html">Installation &amp; environment checks</a>
<a href="https://www.funasr.com/en/docs/quickstart.html">Your first transcription</a>
<a href="https://www.funasr.com/en/docs/python-api.html">Python SDK: AutoModel</a>
@@ -67,7 +68,6 @@
<details open="">
<summary>Models &amp; capabilities</summary>
<nav aria-label="Models &amp; capabilities">
<a href="https://www.funasr.com/en/docs/native-transformers.html">Native Transformers Fun-ASR-Nano</a>
<a href="https://www.funasr.com/en/docs/moss-transcribe-diarize.html">MOSS transcription &amp; diarization</a>
<a href="https://www.funasr.com/en/docs/model-zoo.html">Model Zoo</a>
<a href="https://www.funasr.com/en/docs/streaming-vad.html">Streaming voice activity detection</a>
+3 -3
View File
@@ -56,6 +56,7 @@
<details open="">
<summary>Get started</summary>
<nav aria-label="Get started">
<a href="https://www.funasr.com/en/docs/native-transformers.html">Transformers quickstart</a>
<a href="https://www.funasr.com/en/docs/installation.html">Installation &amp; environment checks</a>
<a href="https://www.funasr.com/en/docs/quickstart.html">Your first transcription</a>
<a href="https://www.funasr.com/en/docs/python-api.html">Python SDK: AutoModel</a>
@@ -67,7 +68,6 @@
<details open="">
<summary>Models &amp; capabilities</summary>
<nav aria-label="Models &amp; capabilities">
<a href="https://www.funasr.com/en/docs/native-transformers.html">Native Transformers Fun-ASR-Nano</a>
<a href="https://www.funasr.com/en/docs/moss-transcribe-diarize.html">MOSS transcription &amp; diarization</a>
<a href="https://www.funasr.com/en/docs/model-zoo.html">Model Zoo</a>
<a href="https://www.funasr.com/en/docs/streaming-vad.html">Streaming voice activity detection</a>
@@ -146,9 +146,9 @@
<tbody>
<tr>
<td>Native Transformers</td>
<td>Python applications using Hugging Face processors and generation</td>
<td>First Nano transcript, notebooks and Hugging Face Python applications</td>
<td><a href="https://www.funasr.com/en/docs/native-transformers.html">Native Fun-ASR-Nano guide</a></td>
<td>Official <code>-hf</code> checkpoint and pinned source; stable 5.16.1 lacks support at the 2026-09-09 check. Python inference, not an HTTP or realtime server.</td>
<td>Released <strong>5.17.0</strong>, official <code>-hf</code> checkpoint, CPU examples and batching. Python inference, not an HTTP or realtime server.</td>
</tr>
<tr>
<td>Colab notebook</td>
+1 -1
View File
@@ -56,6 +56,7 @@
<details open="">
<summary>Get started</summary>
<nav aria-label="Get started">
<a href="https://www.funasr.com/en/docs/native-transformers.html">Transformers quickstart</a>
<a href="https://www.funasr.com/en/docs/installation.html">Installation &amp; environment checks</a>
<a href="https://www.funasr.com/en/docs/quickstart.html">Your first transcription</a>
<a href="https://www.funasr.com/en/docs/python-api.html">Python SDK: AutoModel</a>
@@ -67,7 +68,6 @@
<details open="">
<summary>Models &amp; capabilities</summary>
<nav aria-label="Models &amp; capabilities">
<a href="https://www.funasr.com/en/docs/native-transformers.html">Native Transformers Fun-ASR-Nano</a>
<a href="https://www.funasr.com/en/docs/moss-transcribe-diarize.html">MOSS transcription &amp; diarization</a>
<a href="https://www.funasr.com/en/docs/model-zoo.html">Model Zoo</a>
<a href="https://www.funasr.com/en/docs/streaming-vad.html">Streaming voice activity detection</a>
+4 -1
View File
@@ -56,6 +56,7 @@
<details open="">
<summary>Get started</summary>
<nav aria-label="Get started">
<a href="https://www.funasr.com/en/docs/native-transformers.html">Transformers quickstart</a>
<a href="https://www.funasr.com/en/docs/installation.html">Installation &amp; environment checks</a>
<a href="https://www.funasr.com/en/docs/quickstart.html">Your first transcription</a>
<a href="https://www.funasr.com/en/docs/python-api.html">Python SDK: AutoModel</a>
@@ -67,7 +68,6 @@
<details open="">
<summary>Models &amp; capabilities</summary>
<nav aria-label="Models &amp; capabilities">
<a href="https://www.funasr.com/en/docs/native-transformers.html">Native Transformers Fun-ASR-Nano</a>
<a href="https://www.funasr.com/en/docs/moss-transcribe-diarize.html">MOSS transcription &amp; diarization</a>
<a href="https://www.funasr.com/en/docs/model-zoo.html">Model Zoo</a>
<a href="https://www.funasr.com/en/docs/streaming-vad.html">Streaming voice activity detection</a>
@@ -132,6 +132,8 @@
<nav aria-label="Breadcrumbs" class="breadcrumbs"><a href="https://www.funasr.com/en/">FunASR</a><span>/</span><a href="https://www.funasr.com/en/docs/">Docs</a><span>/</span><span>Choose your first model</span></nav>
<header class="docs-title"><h1>Choose your first model</h1><a class="source-link" data-source-link="" href="https://github.com/modelscope/FunASR/blob/main/docs/model_selection.md">View / edit source ↗</a></header>
<article class="docs-article"><div class="source-title-anchor" id="funasr-model-selection-guide"></div>
<h2 id="transformers-first-nano-evaluation">Transformers-first Nano evaluation</h2>
<p>For Chinese, English and Japanese transcription through Hugging Face APIs, start with <a href="https://www.funasr.com/en/docs/native-transformers.html">native Transformers 5.17.0</a>, the official <code>FunAudioLLM/Fun-ASR-Nano-2512-hf</code> checkpoint and the CPU example. The toolkit and service paths below remain separate; the native export does not add timestamps, speakers or an HTTP endpoint.</p>
<p>Use this guide when you are choosing a first model, comparing FunASR with Whisper or a cloud ASR provider, or deciding which model alias to expose through the OpenAI-compatible API.</p>
<span data-legacy-doc-anchor="fast-default-path" id="default"></span><h2 id="fast-default-path">Fast default path</h2>
<p>For GPU evaluation of Chinese, English, Japanese, or Chinese dialects and regional accents, start with the flagship <strong>Fun-ASR-Nano</strong> (SenseVoice encoder + Qwen3 decoder). Compare it on your own audio before choosing a production model:</p>
@@ -345,6 +347,7 @@ interface and environment together before testing your own workload.</p>
<aside class="docs-toc"><strong>On this page</strong><div class="toc">
<ul>
<li><a href="#funasr-model-selection-guide">FunASR Model Selection Guide</a><ul>
<li><a href="#transformers-first-nano-evaluation">Transformers-first Nano evaluation</a></li>
<li><a href="#fast-default-path">Fast default path</a></li>
<li><a href="#decision-table">Decision table</a></li>
<li><a href="#openai-compatible-api-aliases">OpenAI-compatible API aliases</a></li>
+1 -1
View File
@@ -56,6 +56,7 @@
<details open="">
<summary>Get started</summary>
<nav aria-label="Get started">
<a href="https://www.funasr.com/en/docs/native-transformers.html">Transformers quickstart</a>
<a href="https://www.funasr.com/en/docs/installation.html">Installation &amp; environment checks</a>
<a href="https://www.funasr.com/en/docs/quickstart.html">Your first transcription</a>
<a href="https://www.funasr.com/en/docs/python-api.html">Python SDK: AutoModel</a>
@@ -67,7 +68,6 @@
<details open="">
<summary>Models &amp; capabilities</summary>
<nav aria-label="Models &amp; capabilities">
<a href="https://www.funasr.com/en/docs/native-transformers.html">Native Transformers Fun-ASR-Nano</a>
<a aria-current="page" href="https://www.funasr.com/en/docs/moss-transcribe-diarize.html">MOSS transcription &amp; diarization</a>
<a href="https://www.funasr.com/en/docs/model-zoo.html">Model Zoo</a>
<a href="https://www.funasr.com/en/docs/streaming-vad.html">Streaming voice activity detection</a>
+152 -185
View File
@@ -4,15 +4,15 @@
<head>
<meta charset="utf-8"/>
<meta content="width=device-width, initial-scale=1" name="viewport"/>
<title>Native Transformers Fun-ASR-Nano - FunASR</title>
<meta content="Native Transformers Fun-ASR-Nano" name="description"/>
<title>Transformers quickstart - FunASR</title>
<meta content="Transformers quickstart" name="description"/>
<meta content="#ffffff" name="theme-color"/>
<link href="https://www.funasr.com/en/docs/native-transformers.html" rel="canonical"/>
<link href="https://www.funasr.com/docs/native-transformers.html" hreflang="zh-CN" rel="alternate"/>
<link href="https://www.funasr.com/en/docs/native-transformers.html" hreflang="en" rel="alternate"/>
<meta content="website" property="og:type"/>
<meta content="Native Transformers Fun-ASR-Nano - FunASR" property="og:title"/>
<meta content="Native Transformers Fun-ASR-Nano" property="og:description"/>
<meta content="Transformers quickstart - FunASR" property="og:title"/>
<meta content="Transformers quickstart" property="og:description"/>
<meta content="https://www.funasr.com/en/docs/native-transformers.html" property="og:url"/>
<link href="assets/css/site.7be954c8e106.css" rel="stylesheet"/>
<link href="assets/css/experience.34d6e632686e.css" rel="stylesheet"/>
@@ -56,6 +56,7 @@
<details open="">
<summary>Get started</summary>
<nav aria-label="Get started">
<a aria-current="page" href="https://www.funasr.com/en/docs/native-transformers.html">Transformers quickstart</a>
<a href="https://www.funasr.com/en/docs/installation.html">Installation &amp; environment checks</a>
<a href="https://www.funasr.com/en/docs/quickstart.html">Your first transcription</a>
<a href="https://www.funasr.com/en/docs/python-api.html">Python SDK: AutoModel</a>
@@ -67,7 +68,6 @@
<details open="">
<summary>Models &amp; capabilities</summary>
<nav aria-label="Models &amp; capabilities">
<a aria-current="page" href="https://www.funasr.com/en/docs/native-transformers.html">Native Transformers Fun-ASR-Nano</a>
<a href="https://www.funasr.com/en/docs/moss-transcribe-diarize.html">MOSS transcription &amp; diarization</a>
<a href="https://www.funasr.com/en/docs/model-zoo.html">Model Zoo</a>
<a href="https://www.funasr.com/en/docs/streaming-vad.html">Streaming voice activity detection</a>
@@ -129,130 +129,42 @@
</details>
</aside>
<div class="docs-body">
<nav aria-label="Breadcrumbs" class="breadcrumbs"><a href="https://www.funasr.com/en/">FunASR</a><span>/</span><a href="https://www.funasr.com/en/docs/">Docs</a><span>/</span><span>Native Transformers Fun-ASR-Nano</span></nav>
<header class="docs-title"><h1>Native Transformers Fun-ASR-Nano</h1><a class="source-link" data-source-link="" href="https://github.com/modelscope/FunASR/blob/main/docs/transformers_native.md">View / edit source ↗</a></header>
<article class="docs-article"><div class="source-title-anchor" id="fun-asr-nano-with-native-transformers"></div>
<nav aria-label="Breadcrumbs" class="breadcrumbs"><a href="https://www.funasr.com/en/">FunASR</a><span>/</span><a href="https://www.funasr.com/en/docs/">Docs</a><span>/</span><span>Transformers quickstart</span></nav>
<header class="docs-title"><h1>Transformers quickstart</h1><a class="source-link" data-source-link="" href="https://github.com/modelscope/FunASR/blob/main/docs/transformers_native.md">View / edit source ↗</a></header>
<article class="docs-article"><div class="source-title-anchor" id="fun-asr-nano-with-transformers"></div>
<p><a href="https://www.funasr.com/docs/native-transformers.html">简体中文</a> | English</p>
<p>Use this path when your Python application already works with Hugging Face
processors and generation APIs. It runs Fun-ASR-Nano through native Transformers
classes, without the FunASR toolkit or checkpoint-provided remote Python code.
For a managed HTTP service, start with the <a href="https://www.funasr.com/en/docs/deployment-matrix.html">deployment matrix</a>;
this guide does not add an OpenAI endpoint, request queue or realtime server.</p>
<h2 id="what-was-merged-and-what-was-released">What was merged, and what was released?</h2>
<p>On <strong>2026-09-09</strong>, <a href="https://github.com/huggingface/transformers/pull/46180">Transformers PR #46180</a>
was merged as <code>fc501343edfccdc840eb8594a6cafa8185c2de53</code>.
At verification time that day, the latest stable <strong>5.16.1 did not contain this
model</strong>: both its release tag and actual wheel were inspected. A merge is not
a stable release. The source build identifies itself as <code>5.17.0.dev0</code>; that is
not a promised release version or date. Pin the tested source below, or check
that a later released package really contains <code>fun_asr_nano</code> before migrating.</p>
<h2 id="choose-the-checkpoint-and-the-interface-together">Choose the checkpoint and the interface together</h2>
<table>
<thead>
<tr>
<th>Path</th>
<th>Checkpoint</th>
<th>Entry point</th>
</tr>
</thead>
<tbody>
<tr>
<td>FunASR toolkit</td>
<td><code>FunAudioLLM/Fun-ASR-Nano-2512</code></td>
<td><code>funasr.AutoModel</code>; separate documented split-engine path</td>
</tr>
<tr>
<td>Native Transformers</td>
<td><code>FunAudioLLM/Fun-ASR-Nano-2512-hf</code></td>
<td><code>AutoProcessor</code> + <code>AutoModelForSpeechSeq2Seq</code></td>
</tr>
<tr>
<td>Native vLLM</td>
<td><code>FunAudioLLM/Fun-ASR-Nano-2512-vllm</code></td>
<td><a href="https://www.funasr.com/en/docs/official-native-vllm.html">Official native vLLM guide</a></td>
</tr>
<tr>
<td>Native C++</td>
<td>Converted GGUF files for the chosen runtime</td>
<td><a href="https://github.com/modelscope/FunASR/blob/main/runtime/llama.cpp/README.md">llama.cpp guide</a></td>
</tr>
</tbody>
</table>
<p>These are different artifacts and API contracts. Renaming a model ID or passing
<code>backend="vllm"</code> does not convert weights. Native Transformers support does not
make the <code>-hf</code> checkpoint a vLLM, GGUF or FunASR HTTP-server checkpoint.</p>
<p>The official <a href="https://huggingface.co/FunAudioLLM/Fun-ASR-Nano-2512-hf/tree/d93b302ee7fd505e1b3576120fc142fc6f7820e1">native HF checkpoint</a>
is public and ungated at revision <code>d93b302ee7fd505e1b3576120fc142fc6f7820e1</code>.
Its configuration maps to <code>FunAsrNanoForConditionalGeneration</code>. Its feature
extractor is embedded in <code>processor_config.json</code>; a separate
<code>preprocessor_config.json</code> is not required for this snapshot.</p>
<h2 id="independent-cpu-environment">Independent CPU environment</h2>
<p>Use a new directory for the virtual environment; do not upgrade an existing
FunASR or vLLM service environment in place. The following is <strong>Linux x86-64,
Python 3.12, CPU-only</strong>, not a CUDA or macOS installation recipe.</p>
<p>Transcribe Chinese, English and Japanese with <code>AutoProcessor</code> and
<code>AutoModelForSpeechSeq2Seq</code>. <strong>Transformers 5.17.0 is a released package with
native Fun-ASR-Nano support.</strong> No source checkout, FunASR toolkit or
checkpoint-provided Python code is needed.</p>
<p><a href="https://huggingface.co/spaces/FunAudioLLM/Fun-ASR-Nano">Try the Space</a> ·
<a href="https://colab.research.google.com/github/QwenAudio/Fun-ASR/blob/main/examples/colab/fun_asr_nano_transformers.ipynb">Open the notebook</a> ·
<a href="https://github.com/QwenAudio/Fun-ASR/tree/main/examples/transformers">Runnable examples</a></p>
<h2 id="get-your-first-transcript">Get your first transcript</h2>
<p>Start in an isolated environment. This reproducible installation is for Linux
x86-64, Python 3.12 and <strong>CPU</strong>; do not upgrade an existing vLLM or FunASR service
environment in place. Torch and torchaudio must match because the native
feature extractor uses <code>torchaudio.compliance.kaldi.fbank</code>.</p>
<pre id="code-0"><code class="language-bash">python3.12 -m venv .venv-funasr-native
. .venv-funasr-native/bin/activate
python -m pip install --index-url https://download.pytorch.org/whl/cpu \
'torch==2.10.0+cpu' 'torchaudio==2.10.0+cpu'
python -m pip install 'numpy==1.26.4' 'librosa==0.11.0' 'soundfile==0.13.1' \
'huggingface-hub==1.30.0' 'tokenizers==0.23.2' \
'https://github.com/huggingface/transformers/archive/fc501343edfccdc840eb8594a6cafa8185c2de53.zip'
python -m pip install 'transformers==5.17.0' 'numpy==1.26.4' \
'librosa==0.11.0' 'soundfile==0.13.1' \
'huggingface-hub==1.30.0' 'tokenizers==0.23.2'
python -m pip check
</code></pre>
<p>The verification environment installed a wheel built from the exact source
commit above. Matching <strong>torch and torchaudio</strong> are required for this native
feature extractor: it calls <code>torchaudio.compliance.kaldi.fbank</code>. The toolkit's
optional audio dependencies do not imply that torchaudio is optional here.
Older prepared environments failed dependency gates; do not disable those gates
or mix incompatible Hub/tokenizers versions to get an import to succeed.
This is a tested environment, not a complete lock of every transitive dependency;
record <code>python -m pip freeze</code>, platform details and model revision in your own run.</p>
<h2 id="check-preprocessing-without-loading-weights">Check preprocessing without loading weights</h2>
<p>This downloads the public configuration, tokenizer and chat template, <strong>not
model weights</strong>. One second of synthetic silence checks the entry point; it is
not a speech-recognition quality test.</p>
<!-- native-example: processor -->
<pre id="code-1"><code class="language-python">import numpy as np
from transformers import AutoProcessor
model_id = "FunAudioLLM/Fun-ASR-Nano-2512-hf"
revision = "d93b302ee7fd505e1b3576120fc142fc6f7820e1"
processor = AutoProcessor.from_pretrained(
model_id, revision=revision, trust_remote_code=False, token=False
)
inputs = processor.apply_transcription_request(
audio=np.zeros(16000, dtype=np.float32),
language="en",
processor_kwargs={
"return_tensors": "pt",
"audio_kwargs": {"sampling_rate": 16000},
},
)
print({name: tuple(value.shape) for name, value in inputs.items()})
</code></pre>
<p>In the verified environment the text tensors have shape <code>(1, 42)</code>, audio features
<code>(1, 17, 560)</code>, and feature mask <code>(1, 17)</code>. There are 17 audio placeholder tokens
and 17 valid feature frames. These shapes depend on input length and template;
do not hard-code them for real recordings.</p>
<h2 id="transcribe-one-recording">Transcribe one recording</h2>
<p>Prepare a non-empty <strong>mono 16 kHz WAV</strong> named <code>audio.wav</code> in your working directory.
The code deliberately rejects a different sample rate or channel layout rather
than silently assigning 16 kHz to arbitrary samples. Resample/downmix with an
explicit policy before this step and preserve the original recording for review.</p>
<p>The first model load downloads the weights unless the pinned snapshot is already
cached. It needs substantially more memory and time than preprocessing. This
example uses CPU float32 explicitly; GPU placement, mixed precision, attention
backends and service concurrency need separate validation.</p>
<p>Run this Python example. It downloads about 1.66 GB of model weights on first
use and transcribes a short, pinned official English sample. CPU float32 is
explicit; no GPU is needed for this example.</p>
<!-- native-example: transcribe -->
<pre id="code-2"><code class="language-python">import soundfile as sf
import torch
<pre id="code-1"><code class="language-python">import torch
from transformers import AutoModelForSpeechSeq2Seq, AutoProcessor
torch.set_num_threads(4)
model_id = "FunAudioLLM/Fun-ASR-Nano-2512-hf"
revision = "d93b302ee7fd505e1b3576120fc142fc6f7820e1"
audio, sample_rate = sf.read("audio.wav", dtype="float32")
if sample_rate != 16000 or audio.ndim != 1 or audio.size == 0:
raise ValueError("Use a non-empty mono 16 kHz WAV file")
audio = "https://huggingface.co/FunAudioLLM/Fun-ASR-Nano-2512/resolve/272c57b82523ada6fd87095e955f8e29100979ab/example/en.mp3"
processor = AutoProcessor.from_pretrained(
model_id, revision=revision, trust_remote_code=False, token=False
@@ -262,10 +174,11 @@ model = AutoModelForSpeechSeq2Seq.from_pretrained(
dtype=torch.float32,
).to("cpu").eval()
inputs = processor.apply_transcription_request(
audio=audio, language="zh",
audio=audio, language="en",
processor_kwargs={
"return_tensors": "pt",
"audio_kwargs": {"sampling_rate": sample_rate},
"audio_kwargs": {"sampling_rate": 16000},
"text_kwargs": {"padding": True},
},
)
with torch.inference_mode():
@@ -273,78 +186,132 @@ with torch.inference_mode():
new_tokens = generated[:, inputs.input_ids.shape[1]:]
print(processor.batch_decode(new_tokens, skip_special_tokens=True)[0])
</code></pre>
<p><code>generated</code> includes the input prompt. Slice off <code>inputs.input_ids.shape[1]</code>
before decoding so prompt framing is not mistaken for recognized speech.
<code>max_new_tokens=128</code> bounds this short-file example; hitting the limit can
truncate output. A longer limit is not proof of complete coverage.
Use <code>language="en"</code> or <code>language="ja"</code> for the corresponding target language;
language selection is a transcription instruction, not a promise of translation.</p>
<h2 id="context-hotwords-and-batches">Context, hotwords and batches</h2>
<p><code>apply_transcription_request</code> accepts <code>prompt</code> for context and <code>keywords</code> for
hotwords. These are native processor arguments, not the toolkit's <code>hotword</code>
parameter or a vLLM HTTP field. The source API accepts one language for the batch
or a language list matching its length; per-recording prompt and nested keyword
lists must also match the batch. Keep the decoded results in input order.</p>
<p>Do not infer quality gains from a template accepting a keyword. Evaluate names,
numbers and unusual terms against authorized, representative recordings.
Batch padding, memory use and generated-text correctness must be tested together
before turning a single-file example into a production batch worker.</p>
<h2 id="evidence-and-limits">Evidence and limits</h2>
<p>The documented single-recording recipe was also executed on the official Chinese
sample, followed by an English single recording, a Chinese keyword request and a
Chinese/English batch. All returned non-empty text and EOS before the 128-token
limit. These are functional checks on two short public samples, not a CER/WER or
capacity evaluation. CPU: Intel Xeon Platinum 8480+, float32, four Torch threads;
matching torch/torchaudio 2.10.0+cpu and librosa 0.11.0. Model weights were loaded
from a previously downloaded official cache whose SHA/size were rechecked.</p>
<p>Samples came from the original model's
<p>The model returns the prompt and generated tokens together. Remove the full
input tensor width before decoding. For this sample, the observed raw output
was: “The tribal chieftain called for the boy, and presented him with fifty
pieces of gold.” This is a functional example, not a quality guarantee.</p>
<h2 id="your-files-keywords-and-batches">Your files, keywords and batches</h2>
<p>The <a href="https://github.com/QwenAudio/Fun-ASR/tree/main/examples/transformers">command-line example</a>
adds explicit input validation, sample-rate conversion and completion checks.
Clone the <strong>QwenAudio/Fun-ASR code repository</strong> (not an HF weights repository),
install the <a href="https://github.com/QwenAudio/Fun-ASR/tree/main/examples/transformers">independent native requirements</a>,
and run these commands from its root directory:</p>
<pre id="code-2"><code class="language-bash">python examples/transformers/transcribe.py recording.wav --language zh --keywords 开放时间
python examples/transformers/transcribe.py chinese.wav english.wav --language zh en
</code></pre>
<p>It averages multichannel audio to mono and resamples to 16 kHz with <code>soxr_hq</code>;
it never overwrites the original file. It accepts 1-4 files with at most
60 seconds of total audio. Longer recordings, empty input and non-finite samples
are rejected, not silently trimmed.</p>
<p>For your own application, pass a waveform, local path or supported URL to
<code>processor.apply_transcription_request</code>. A raw waveform must have its true
sample rate; do not label 48 kHz samples as 16 kHz. Use <code>language="zh"</code>,
<code>"en"</code> or <code>"ja"</code>. For a batch, use an audio list, matching language list and
<code>text_kwargs={"padding": True}</code>. Preserve input order when decoding.</p>
<p><code>keywords</code> supplies vocabulary hints and <code>prompt</code> supplies context. They are
not enforced vocabulary and are not the toolkit's <code>hotword</code> parameter. In our
Chinese sample, adding <code>开放时间</code> did not correct the raw output <code>开饭时间</code>.
Use representative recordings and human references to assess quality.</p>
<p>The short example bounds generation at 128 new tokens. Missing EOS can indicate
truncation; increasing the limit does not prove coverage of a long recording.
The CLI reports <code>reached_eos</code> and exits unsuccessfully for missing EOS or empty
text. EOS itself is not proof that all words were recognized.</p>
<h2 id="from-an-example-to-a-service">From an example to a service</h2>
<table>
<thead>
<tr>
<th>Need</th>
<th>Checkpoint and interface</th>
</tr>
</thead>
<tbody>
<tr>
<td>Native Transformers in Python</td>
<td><code>FunAudioLLM/Fun-ASR-Nano-2512-hf</code>, <code>AutoProcessor</code> + <code>AutoModelForSpeechSeq2Seq</code></td>
</tr>
<tr>
<td>FunASR pipelines and HTTP adapters</td>
<td><code>FunAudioLLM/Fun-ASR-Nano-2512</code>, <code>funasr.AutoModel</code>; <a href="https://www.funasr.com/en/docs/deployment-matrix.html">deployment matrix</a></td>
</tr>
<tr>
<td>Native vLLM</td>
<td><code>FunAudioLLM/Fun-ASR-Nano-2512-vllm</code>; <a href="https://www.funasr.com/en/docs/official-native-vllm.html">native vLLM guide</a></td>
</tr>
<tr>
<td>C++ / edge</td>
<td>Converted GGUF files; <a href="https://github.com/modelscope/FunASR/blob/main/runtime/llama.cpp/README.md">llama.cpp</a></td>
</tr>
</tbody>
</table>
<p>These are different artifacts, not interchangeable model IDs. Native
Transformers support does not add an HTTP server, queue, streaming protocol,
word timestamps or speaker identities. This native export omits the CTC
timestamp branch. The base Nano checkpoint covers zh/en/ja and Chinese
dialects/accents; the <strong>31-language MLT</strong> checkpoint is separate.</p>
<p>For transcription with anonymous speakers and segment timestamps, see the
third-party OpenMOSS <a href="https://www.funasr.com/en/docs/moss-transcribe-diarize.html">MOSS guide</a>. For other tasks,
use the <a href="https://www.funasr.com/en/docs/model-zoo.html">Model Zoo</a>. Validate GPU dtype, attention
backends, memory, concurrency and quality on the actual target hardware.</p>
<h2 id="troubleshooting-without-loading-weights">Troubleshooting without loading weights</h2>
<p>If loading fails, check the active interpreter, <code>transformers.__version__</code>,
the <code>-hf</code> model ID and model revision first. Version 5.16.1 lacks this model;
upgrade in the new environment, not an unrelated running service. The native
classes live in <code>transformers.models.fun_asr_nano</code>.</p>
<p>This optional synthetic-silence check downloads the processor, not model weights:</p>
<!-- native-example: processor -->
<pre id="code-3"><code class="language-python">import numpy as np
from transformers import AutoProcessor
model_id = "FunAudioLLM/Fun-ASR-Nano-2512-hf"
revision = "d93b302ee7fd505e1b3576120fc142fc6f7820e1"
processor = AutoProcessor.from_pretrained(
model_id, revision=revision, trust_remote_code=False, token=False
)
inputs = processor.apply_transcription_request(
audio=np.zeros(16000, dtype=np.float32), language="en",
processor_kwargs={
"return_tensors": "pt",
"audio_kwargs": {"sampling_rate": 16000},
},
)
print({name: tuple(value.shape) for name, value in inputs.items()})
</code></pre>
<p>Reject empty recordings and batches before calling the processor. Synthetic
preprocessing success is <strong>not an accuracy or capacity result</strong>.</p>
<h2 id="reproducibility-and-sources">Reproducibility and sources</h2>
<p>Verified on <strong>2026-09-09</strong> using the actual released 5.17.0 wheel, Python 3.12.3,
matching torch/torchaudio 2.10.0+cpu, float32 and four Torch threads on an Intel
Xeon Platinum 8480+. Official English URL, Chinese waveform, Chinese keywords
and a padded Chinese/English batch all returned non-empty text and EOS before
128 tokens. These two short public samples do not establish CER/WER, GPU
compatibility or serving capacity.</p>
<p>The public native revision is
<code>d93b302ee7fd505e1b3576120fc142fc6f7820e1</code>; it resolves to
<code>FunAsrNanoForConditionalGeneration</code> with <code>trust_remote_code=False</code>.
<code>model.safetensors</code> is 1,659,773,320 bytes, SHA256
<code>1bbb6dcc5d8b75084a399d48c4d4b0f3aa1d3f09f2616ae40ed2c4fba03d89c9</code>.
Audio samples come from the original repository's
<a href="https://huggingface.co/FunAudioLLM/Fun-ASR-Nano-2512/tree/272c57b82523ada6fd87095e955f8e29100979ab/example">fixed example directory</a>,
not from an invented -hf example directory. The mono 48 kHz Chinese MP3 was
explicitly resampled with librosa's default soxr_hq and written as float32 16 kHz
WAV before running the unmodified recipe. Its raw text was
<code>开饭时间早上九点至下午五点。</code>; adding the candidate keyword <code>开放时间</code> did not force that
spelling into the output. A keyword is a hint, not an enforced vocabulary.</p>
<p>Synthetic processor tests exercised language aliases, context/keyword lists and
two-length batches. The empty-list case still raises an upstream <code>IndexError</code>
before its intended validation; reject empty batches in your application.
The guide's explicit non-empty waveform check avoids that entry path. Successful
cases do not erase this observed limitation. Initial resampling also exposed the
old librosa 0.10.1 dependency on removed <code>pkg_resources</code>; the final environment
uses 0.11.0 and was retested.</p>
<p>The 2026-09-09 isolated CPU verification passed package dependency checks,
native configuration/class resolution and synthetic preprocessing with the
pinned official revision. Installed configuration, modeling, processing and
feature-extraction files were byte-identical to the merged upstream source.
A preprocessing pass is <strong>not an accuracy or capacity result</strong>. It does not
establish word timestamps, diarization, realtime behavior, GPU compatibility,
or performance equivalence with vLLM.</p>
<p>For anonymous speakers and segment timestamps, see the third-party OpenMOSS
<a href="https://www.funasr.com/en/docs/moss-transcribe-diarize.html">MOSS guide</a>; for other choices see the
<a href="https://www.funasr.com/en/docs/model-zoo.html">Model Zoo</a>. Do not infer timestamp or identity support
from a model returning text. Preserve input hashes, versions, raw responses and
an authorized human review when assessing an application. Never attach private
recordings or credentials to a public issue.</p>
<h2 id="sources-and-next-steps">Sources and next steps</h2>
<ul>
<li><a href="https://github.com/huggingface/transformers/blob/fc501343edfccdc840eb8594a6cafa8185c2de53/docs/source/en/model_doc/fun_asr_nano.md">Merged implementation and usage documentation</a>.</li>
<li><a href="https://github.com/huggingface/transformers/blob/fc501343edfccdc840eb8594a6cafa8185c2de53/src/transformers/models/fun_asr_nano/processing_fun_asr_nano.py">Native processor</a> and <a href="https://github.com/huggingface/transformers/blob/fc501343edfccdc840eb8594a6cafa8185c2de53/src/transformers/models/fun_asr_nano/feature_extraction_fun_asr_nano.py">audio feature extractor</a>.</li>
<li><a href="https://www.funasr.com/en/blog/fun-asr-nano-transformers.html">Why the checkpoint suffix matters</a>, an application-oriented walkthrough.</li>
<li><a href="https://github.com/QwenAudio/Fun-ASR">Fun-ASR model project</a> and <a href="https://github.com/modelscope/FunASR">FunASR toolkit</a>.</li>
</ul></article>
not an invented <code>-hf/example</code> path.</p>
<p><a href="https://github.com/huggingface/transformers/pull/46180">PR #46180</a> merged as
<code>fc501343edfccdc840eb8594a6cafa8185c2de53</code> before the stable package was
published. Earlier source-only instructions described that interval; new
installations should use the released package above.
See the <a href="https://huggingface.co/docs/transformers/v5.17.0/en/model_doc/fun_asr_nano">official 5.17.0 model documentation</a>
and <a href="https://huggingface.co/FunAudioLLM/Fun-ASR-Nano-2512-hf">native model card</a>.</p>
<p>Keep versions, input hashes and raw results with application evaluations.
Never attach private recordings or credentials to a public issue.</p></article>
<nav aria-label="Adjacent documents" class="docs-next">
<a href="https://www.funasr.com/en/docs/installation.html">Installation &amp; environment checks →</a> </nav>
</div>
<aside class="docs-toc"><strong>On this page</strong><div class="toc">
<ul>
<li><a href="#fun-asr-nano-with-native-transformers">Fun-ASR-Nano with native Transformers</a><ul>
<li><a href="#what-was-merged-and-what-was-released">What was merged, and what was released?</a></li>
<li><a href="#choose-the-checkpoint-and-the-interface-together">Choose the checkpoint and the interface together</a></li>
<li><a href="#independent-cpu-environment">Independent CPU environment</a></li>
<li><a href="#check-preprocessing-without-loading-weights">Check preprocessing without loading weights</a></li>
<li><a href="#transcribe-one-recording">Transcribe one recording</a></li>
<li><a href="#context-hotwords-and-batches">Context, hotwords and batches</a></li>
<li><a href="#evidence-and-limits">Evidence and limits</a></li>
<li><a href="#sources-and-next-steps">Sources and next steps</a></li>
<li><a href="#fun-asr-nano-with-transformers">Fun-ASR-Nano with Transformers</a><ul>
<li><a href="#get-your-first-transcript">Get your first transcript</a></li>
<li><a href="#your-files-keywords-and-batches">Your files, keywords and batches</a></li>
<li><a href="#from-an-example-to-a-service">From an example to a service</a></li>
<li><a href="#troubleshooting-without-loading-weights">Troubleshooting without loading weights</a></li>
<li><a href="#reproducibility-and-sources">Reproducibility and sources</a></li>
</ul>
</li>
</ul>
+1 -1
View File
@@ -56,6 +56,7 @@
<details open="">
<summary>Get started</summary>
<nav aria-label="Get started">
<a href="https://www.funasr.com/en/docs/native-transformers.html">Transformers quickstart</a>
<a href="https://www.funasr.com/en/docs/installation.html">Installation &amp; environment checks</a>
<a href="https://www.funasr.com/en/docs/quickstart.html">Your first transcription</a>
<a href="https://www.funasr.com/en/docs/python-api.html">Python SDK: AutoModel</a>
@@ -67,7 +68,6 @@
<details open="">
<summary>Models &amp; capabilities</summary>
<nav aria-label="Models &amp; capabilities">
<a href="https://www.funasr.com/en/docs/native-transformers.html">Native Transformers Fun-ASR-Nano</a>
<a href="https://www.funasr.com/en/docs/moss-transcribe-diarize.html">MOSS transcription &amp; diarization</a>
<a href="https://www.funasr.com/en/docs/model-zoo.html">Model Zoo</a>
<a href="https://www.funasr.com/en/docs/streaming-vad.html">Streaming voice activity detection</a>
+4 -1
View File
@@ -56,6 +56,7 @@
<details open="">
<summary>Get started</summary>
<nav aria-label="Get started">
<a href="https://www.funasr.com/en/docs/native-transformers.html">Transformers quickstart</a>
<a href="https://www.funasr.com/en/docs/installation.html">Installation &amp; environment checks</a>
<a aria-current="page" href="https://www.funasr.com/en/docs/quickstart.html">Your first transcription</a>
<a href="https://www.funasr.com/en/docs/python-api.html">Python SDK: AutoModel</a>
@@ -67,7 +68,6 @@
<details open="">
<summary>Models &amp; capabilities</summary>
<nav aria-label="Models &amp; capabilities">
<a href="https://www.funasr.com/en/docs/native-transformers.html">Native Transformers Fun-ASR-Nano</a>
<a href="https://www.funasr.com/en/docs/moss-transcribe-diarize.html">MOSS transcription &amp; diarization</a>
<a href="https://www.funasr.com/en/docs/model-zoo.html">Model Zoo</a>
<a href="https://www.funasr.com/en/docs/streaming-vad.html">Streaming voice activity detection</a>
@@ -133,6 +133,9 @@
<header class="docs-title"><h1>Your first transcription</h1><a class="source-link" data-source-link="" href="https://github.com/modelscope/FunASR/blob/main/docs/tutorial/README.md">View / edit source ↗</a></header>
<article class="docs-article"><p>(<a href="https://www.funasr.com/docs/quickstart.html">简体中文</a> | English)</p>
<div class="source-title-anchor" id="python-sdk-tutorial"></div>
<blockquote>
<p><strong>Only need native Fun-ASR-Nano transcription?</strong> Start with <a href="https://www.funasr.com/en/docs/native-transformers.html">Transformers 5.17.0</a>. It loads the separate <code>-hf</code> checkpoint without the FunASR toolkit. This page covers the <code>funasr.AutoModel</code> toolkit path; do not mix dependencies, parameters or output contracts.</p>
</blockquote>
<p>Start with <a href="https://www.funasr.com/en/docs/installation.html">installation and environment verification</a>. This path covers one transcript, result inspection, VAD, batching, and model-specific options. For model selection, languages, dependencies, and model cards, use the <a href="https://www.funasr.com/en/docs/model-zoo.html">Model Zoo</a>, not a universal capability list. No local setup yet? See the <a href="https://github.com/modelscope/FunASR/blob/main/examples/colab/README.md">Colab quickstart</a>.</p>
<p>FunASR software uses the <a href="https://github.com/modelscope/FunASR/blob/main/LICENSE">MIT license</a>. Each model weight has its own license: record the full model ID and revision, and follow its model card. The <a href="https://github.com/modelscope/FunASR/blob/main/MODEL_LICENSE">FunASR Model License Agreement</a> applies only when the model card explicitly links to it. Third-party integrations remain third-party models; for example, MOSS-Transcribe-Diarize is from OpenMOSS, not a FunASR-trained checkpoint.</p>
<p><a id="Inference" name="Inference"></a></p>
+1 -1
View File
@@ -56,6 +56,7 @@
<details open="">
<summary>Get started</summary>
<nav aria-label="Get started">
<a href="https://www.funasr.com/en/docs/native-transformers.html">Transformers quickstart</a>
<a href="https://www.funasr.com/en/docs/installation.html">Installation &amp; environment checks</a>
<a href="https://www.funasr.com/en/docs/quickstart.html">Your first transcription</a>
<a href="https://www.funasr.com/en/docs/python-api.html">Python SDK: AutoModel</a>
@@ -67,7 +68,6 @@
<details open="">
<summary>Models &amp; capabilities</summary>
<nav aria-label="Models &amp; capabilities">
<a href="https://www.funasr.com/en/docs/native-transformers.html">Native Transformers Fun-ASR-Nano</a>
<a href="https://www.funasr.com/en/docs/moss-transcribe-diarize.html">MOSS transcription &amp; diarization</a>
<a href="https://www.funasr.com/en/docs/model-zoo.html">Model Zoo</a>
<a href="https://www.funasr.com/en/docs/streaming-vad.html">Streaming voice activity detection</a>
+1 -1
View File
@@ -56,6 +56,7 @@
<details open="">
<summary>开始使用</summary>
<nav aria-label="开始使用">
<a href="https://www.funasr.com/docs/native-transformers.html">Transformers 快速开始</a>
<a href="https://www.funasr.com/docs/installation.html">安装与环境验证</a>
<a href="https://www.funasr.com/docs/quickstart.html">第一次转写</a>
<a href="https://www.funasr.com/docs/python-api.html">Python SDK: AutoModel</a>
@@ -67,7 +68,6 @@
<details open="">
<summary>模型与能力</summary>
<nav aria-label="模型与能力">
<a href="https://www.funasr.com/docs/native-transformers.html">Transformers 原生 Fun-ASR-Nano</a>
<a href="https://www.funasr.com/docs/moss-transcribe-diarize.html">MOSS 转写与说话人分离</a>
<a href="https://www.funasr.com/docs/model-zoo.html">Model Zoo</a>
<a href="https://www.funasr.com/docs/streaming-vad.html">流式语音活动检测</a>
+1 -1
View File
@@ -56,6 +56,7 @@
<details open="">
<summary>开始使用</summary>
<nav aria-label="开始使用">
<a href="https://www.funasr.com/docs/native-transformers.html">Transformers 快速开始</a>
<a href="https://www.funasr.com/docs/installation.html">安装与环境验证</a>
<a href="https://www.funasr.com/docs/quickstart.html">第一次转写</a>
<a href="https://www.funasr.com/docs/python-api.html">Python SDK: AutoModel</a>
@@ -67,7 +68,6 @@
<details open="">
<summary>模型与能力</summary>
<nav aria-label="模型与能力">
<a href="https://www.funasr.com/docs/native-transformers.html">Transformers 原生 Fun-ASR-Nano</a>
<a href="https://www.funasr.com/docs/moss-transcribe-diarize.html">MOSS 转写与说话人分离</a>
<a href="https://www.funasr.com/docs/model-zoo.html">Model Zoo</a>
<a href="https://www.funasr.com/docs/streaming-vad.html">流式语音活动检测</a>
+3 -3
View File
@@ -56,6 +56,7 @@
<details open="">
<summary>开始使用</summary>
<nav aria-label="开始使用">
<a href="https://www.funasr.com/docs/native-transformers.html">Transformers 快速开始</a>
<a href="https://www.funasr.com/docs/installation.html">安装与环境验证</a>
<a href="https://www.funasr.com/docs/quickstart.html">第一次转写</a>
<a href="https://www.funasr.com/docs/python-api.html">Python SDK: AutoModel</a>
@@ -67,7 +68,6 @@
<details open="">
<summary>模型与能力</summary>
<nav aria-label="模型与能力">
<a href="https://www.funasr.com/docs/native-transformers.html">Transformers 原生 Fun-ASR-Nano</a>
<a href="https://www.funasr.com/docs/moss-transcribe-diarize.html">MOSS 转写与说话人分离</a>
<a href="https://www.funasr.com/docs/model-zoo.html">Model Zoo</a>
<a href="https://www.funasr.com/docs/streaming-vad.html">流式语音活动检测</a>
@@ -146,9 +146,9 @@
<tbody>
<tr>
<td>原生 Transformers</td>
<td>已使用 Hugging Face 处理器与生成接口的 Python 应用</td>
<td>Nano 首次转写、Notebook 与 Hugging Face Python 应用</td>
<td><a href="https://www.funasr.com/docs/native-transformers.html">原生 Fun-ASR-Nano 指南</a></td>
<td>官方 <code>-hf</code> checkpoint 与固定源码;2026-09-09 核验的稳定版 5.16.1 尚未包含。是 Python 推理入口,不是 HTTP 或实时服务器。</td>
<td>正式版 <strong>5.17.0</strong>,官方 <code>-hf</code> checkpoint,CPU 与批处理示例。是 Python 推理入口,不是 HTTP 或实时服务器。</td>
</tr>
<tr>
<td>Colab Notebook</td>
+1 -1
View File
@@ -56,6 +56,7 @@
<details open="">
<summary>开始使用</summary>
<nav aria-label="开始使用">
<a href="https://www.funasr.com/docs/native-transformers.html">Transformers 快速开始</a>
<a href="https://www.funasr.com/docs/installation.html">安装与环境验证</a>
<a href="https://www.funasr.com/docs/quickstart.html">第一次转写</a>
<a href="https://www.funasr.com/docs/python-api.html">Python SDK: AutoModel</a>
@@ -67,7 +68,6 @@
<details open="">
<summary>模型与能力</summary>
<nav aria-label="模型与能力">
<a href="https://www.funasr.com/docs/native-transformers.html">Transformers 原生 Fun-ASR-Nano</a>
<a href="https://www.funasr.com/docs/moss-transcribe-diarize.html">MOSS 转写与说话人分离</a>
<a href="https://www.funasr.com/docs/model-zoo.html">Model Zoo</a>
<a href="https://www.funasr.com/docs/streaming-vad.html">流式语音活动检测</a>
+4 -1
View File
@@ -56,6 +56,7 @@
<details open="">
<summary>开始使用</summary>
<nav aria-label="开始使用">
<a href="https://www.funasr.com/docs/native-transformers.html">Transformers 快速开始</a>
<a href="https://www.funasr.com/docs/installation.html">安装与环境验证</a>
<a href="https://www.funasr.com/docs/quickstart.html">第一次转写</a>
<a href="https://www.funasr.com/docs/python-api.html">Python SDK: AutoModel</a>
@@ -67,7 +68,6 @@
<details open="">
<summary>模型与能力</summary>
<nav aria-label="模型与能力">
<a href="https://www.funasr.com/docs/native-transformers.html">Transformers 原生 Fun-ASR-Nano</a>
<a href="https://www.funasr.com/docs/moss-transcribe-diarize.html">MOSS 转写与说话人分离</a>
<a href="https://www.funasr.com/docs/model-zoo.html">Model Zoo</a>
<a href="https://www.funasr.com/docs/streaming-vad.html">流式语音活动检测</a>
@@ -132,6 +132,8 @@
<nav aria-label="面包屑" class="breadcrumbs"><a href="https://www.funasr.com/">FunASR</a><span>/</span><a href="https://www.funasr.com/docs/">文档</a><span>/</span><span>选择第一个模型</span></nav>
<header class="docs-title"><h1>选择第一个模型</h1><a class="source-link" data-source-link="" href="https://github.com/modelscope/FunASR/blob/main/docs/model_selection_zh.md">查看 / 编辑源文档 ↗</a></header>
<article class="docs-article"><div class="source-title-anchor" id="funasr-模型选择指南"></div>
<h2 id="先用-transformers-体验-nano">先用 Transformers 体验 Nano</h2>
<p>通过 Hugging Face API 转写中、英、日语音,先用 <a href="https://www.funasr.com/docs/native-transformers.html">原生 Transformers 5.17.0</a>、官方 <code>FunAudioLLM/Fun-ASR-Nano-2512-hf</code> 权重和 CPU 示例。下文的工具库与服务路径仍独立;原生导出不自动提供时间戳、说话人或 HTTP 接口。</p>
<p>当你第一次选择模型、评估是否从 Whisper 或云端 ASR 迁移,或者准备通过 OpenAI 兼容 API 暴露模型别名时,可以先看这份指南。</p>
<span data-legacy-doc-anchor="默认快速路径" id="default"></span><h2 id="默认快速路径">默认快速路径</h2>
<p>如果有 GPU,需要评估中文、英文、日语或中文方言和地域口音,可以先试旗舰 <strong>Fun-ASR-Nano</strong>(SenseVoice 编码器 + Qwen3 解码器)。确定生产模型前,请用自己的音频做对比:</p>
@@ -339,6 +341,7 @@ MOSS 请遵循其独立部署指南:以上 Nano 权重和验证不能证明 MO
<aside class="docs-toc"><strong>本页目录</strong><div class="toc">
<ul>
<li><a href="#funasr-模型选择指南">FunASR 模型选择指南</a><ul>
<li><a href="#先用-transformers-体验-nano">先用 Transformers 体验 Nano</a></li>
<li><a href="#默认快速路径">默认快速路径</a></li>
<li><a href="#决策表">决策表</a></li>
<li><a href="#openai-兼容-api-别名">OpenAI 兼容 API 别名</a></li>
+1 -1
View File
@@ -56,6 +56,7 @@
<details open="">
<summary>开始使用</summary>
<nav aria-label="开始使用">
<a href="https://www.funasr.com/docs/native-transformers.html">Transformers 快速开始</a>
<a href="https://www.funasr.com/docs/installation.html">安装与环境验证</a>
<a href="https://www.funasr.com/docs/quickstart.html">第一次转写</a>
<a href="https://www.funasr.com/docs/python-api.html">Python SDK: AutoModel</a>
@@ -67,7 +68,6 @@
<details open="">
<summary>模型与能力</summary>
<nav aria-label="模型与能力">
<a href="https://www.funasr.com/docs/native-transformers.html">Transformers 原生 Fun-ASR-Nano</a>
<a aria-current="page" href="https://www.funasr.com/docs/moss-transcribe-diarize.html">MOSS 转写与说话人分离</a>
<a href="https://www.funasr.com/docs/model-zoo.html">Model Zoo</a>
<a href="https://www.funasr.com/docs/streaming-vad.html">流式语音活动检测</a>
+136 -159
View File
@@ -4,15 +4,15 @@
<head>
<meta charset="utf-8"/>
<meta content="width=device-width, initial-scale=1" name="viewport"/>
<title>Transformers 原生 Fun-ASR-Nano - FunASR</title>
<meta content="Transformers 原生 Fun-ASR-Nano" name="description"/>
<title>Transformers 快速开始 - FunASR</title>
<meta content="Transformers 快速开始" name="description"/>
<meta content="#ffffff" name="theme-color"/>
<link href="https://www.funasr.com/docs/native-transformers.html" rel="canonical"/>
<link href="https://www.funasr.com/en/docs/native-transformers.html" hreflang="en" rel="alternate"/>
<link href="https://www.funasr.com/docs/native-transformers.html" hreflang="zh-CN" rel="alternate"/>
<meta content="website" property="og:type"/>
<meta content="Transformers 原生 Fun-ASR-Nano - FunASR" property="og:title"/>
<meta content="Transformers 原生 Fun-ASR-Nano" property="og:description"/>
<meta content="Transformers 快速开始 - FunASR" property="og:title"/>
<meta content="Transformers 快速开始" property="og:description"/>
<meta content="https://www.funasr.com/docs/native-transformers.html" property="og:url"/>
<link href="../assets/css/site.7be954c8e106.css" rel="stylesheet"/>
<link href="../assets/css/experience.34d6e632686e.css" rel="stylesheet"/>
@@ -56,6 +56,7 @@
<details open="">
<summary>开始使用</summary>
<nav aria-label="开始使用">
<a aria-current="page" href="https://www.funasr.com/docs/native-transformers.html">Transformers 快速开始</a>
<a href="https://www.funasr.com/docs/installation.html">安装与环境验证</a>
<a href="https://www.funasr.com/docs/quickstart.html">第一次转写</a>
<a href="https://www.funasr.com/docs/python-api.html">Python SDK: AutoModel</a>
@@ -67,7 +68,6 @@
<details open="">
<summary>模型与能力</summary>
<nav aria-label="模型与能力">
<a aria-current="page" href="https://www.funasr.com/docs/native-transformers.html">Transformers 原生 Fun-ASR-Nano</a>
<a href="https://www.funasr.com/docs/moss-transcribe-diarize.html">MOSS 转写与说话人分离</a>
<a href="https://www.funasr.com/docs/model-zoo.html">Model Zoo</a>
<a href="https://www.funasr.com/docs/streaming-vad.html">流式语音活动检测</a>
@@ -129,118 +129,39 @@
</details>
</aside>
<div class="docs-body">
<nav aria-label="面包屑" class="breadcrumbs"><a href="https://www.funasr.com/">FunASR</a><span>/</span><a href="https://www.funasr.com/docs/">文档</a><span>/</span><span>Transformers 原生 Fun-ASR-Nano</span></nav>
<header class="docs-title"><h1>Transformers 原生 Fun-ASR-Nano</h1><a class="source-link" data-source-link="" href="https://github.com/modelscope/FunASR/blob/main/docs/transformers_native_zh.md">查看 / 编辑源文档 ↗</a></header>
<article class="docs-article"><div class="source-title-anchor" id="用原生-transformers-接入-fun-asr-nano"></div>
<nav aria-label="面包屑" class="breadcrumbs"><a href="https://www.funasr.com/">FunASR</a><span>/</span><a href="https://www.funasr.com/docs/">文档</a><span>/</span><span>Transformers 快速开始</span></nav>
<header class="docs-title"><h1>Transformers 快速开始</h1><a class="source-link" data-source-link="" href="https://github.com/modelscope/FunASR/blob/main/docs/transformers_native_zh.md">查看 / 编辑源文档 ↗</a></header>
<article class="docs-article"><div class="source-title-anchor" id="用-transformers-转写-fun-asr-nano"></div>
<p>简体中文 | <a href="https://www.funasr.com/en/docs/native-transformers.html">English</a></p>
<p>如果 Python 应用已经使用 Hugging Face 的处理器和生成接口,可以选择这条路径。
它通过 Transformers 原生类运行 Fun-ASR-Nano,不依赖 FunASR 工具包或 checkpoint
中的远程 Python 代码。需要 HTTP 服务时先看<a href="https://www.funasr.com/docs/deployment-matrix.html">部署矩阵</a>:
本指南不会自动提供 OpenAI 接口、请求队列或实时服务器。</p>
<h2 id="合入主线不等于已经发布">合入主线,不等于已经发布</h2>
<p><strong>2026-09-09</strong>,<a href="https://github.com/huggingface/transformers/pull/46180">Transformers PR #46180</a>
合入提交 <code>fc501343edfccdc840eb8594a6cafa8185c2de53</code>。
当天核验时,最新稳定版 <strong>5.16.1 不包含这个模型</strong>,其 tag 和实际 wheel 均已检查。
源码构建显示 <code>5.17.0.dev0</code>,不代表下一稳定版的版本或发布日期承诺。
请固定下方经过验证的源码提交;改用后续稳定版前,实际确认安装包包含 <code>fun_asr_nano</code>。</p>
<h2 id="模型格式和接口一起选">模型格式和接口一起选</h2>
<table>
<thead>
<tr>
<th>路径</th>
<th>Checkpoint</th>
<th>入口</th>
</tr>
</thead>
<tbody>
<tr>
<td>FunASR 工具包</td>
<td><code>FunAudioLLM/Fun-ASR-Nano-2512</code></td>
<td><code>funasr.AutoModel</code>;拆分引擎另见对应文档</td>
</tr>
<tr>
<td>原生 Transformers</td>
<td><code>FunAudioLLM/Fun-ASR-Nano-2512-hf</code></td>
<td><code>AutoProcessor</code> + <code>AutoModelForSpeechSeq2Seq</code></td>
</tr>
<tr>
<td>原生 vLLM</td>
<td><code>FunAudioLLM/Fun-ASR-Nano-2512-vllm</code></td>
<td><a href="https://www.funasr.com/docs/official-native-vllm.html">官方原生 vLLM 指南</a></td>
</tr>
<tr>
<td>原生 C++</td>
<td>对应运行时转换后的 GGUF 文件</td>
<td><a href="https://github.com/modelscope/FunASR/blob/main/runtime/llama.cpp/README.md">llama.cpp 指南</a></td>
</tr>
</tbody>
</table>
<p>这些产物及 API 契约不同。改模型 ID 的名字或传 <code>backend="vllm"</code> 不会转换权重;
原生 Transformers 支持不意味着 <code>-hf</code> 可以交给 vLLM、GGUF 运行时或 FunASR HTTP 服务。</p>
<p>官方<a href="https://huggingface.co/FunAudioLLM/Fun-ASR-Nano-2512-hf/tree/d93b302ee7fd505e1b3576120fc142fc6f7820e1">原生 HF checkpoint</a>
在 revision <code>d93b302ee7fd505e1b3576120fc142fc6f7820e1</code> 公开且无需申请访问。
配置映射到 <code>FunAsrNanoForConditionalGeneration</code>,特征提取器嵌在
<code>processor_config.json</code> 中。此快照不需要另一个 <code>preprocessor_config.json</code>。</p>
<h2 id="准备独立的-cpu-环境">准备独立的 CPU 环境</h2>
<p>使用新目录创建虚拟环境,不要直接升级正在运行的 FunASR/vLLM 服务环境。
下面对应 <strong>Linux x86-64、Python 3.12、仅 CPU</strong>,不是 CUDA 或 macOS 安装方案。</p>
<p>用 <code>AutoProcessor</code> 和 <code>AutoModelForSpeechSeq2Seq</code> 转写中、英、日语音。
<strong>正式发布的 Transformers 5.17.0 已包含 Fun-ASR-Nano 原生支持。</strong>
不需要克隆源码、安装 FunASR 工具库,也不需要执行模型仓库的远程 Python 代码。</p>
<p><a href="https://huggingface.co/spaces/FunAudioLLM/Fun-ASR-Nano">在线 Space</a> ·
<a href="https://colab.research.google.com/github/QwenAudio/Fun-ASR/blob/main/examples/colab/fun_asr_nano_transformers.ipynb">打开 Notebook</a> ·
<a href="https://github.com/QwenAudio/Fun-ASR/tree/main/examples/transformers">可运行示例</a></p>
<h2 id="先得到第一条转写">先得到第一条转写</h2>
<p>使用独立环境。下面是已验证的 Linux x86-64、Python 3.12 <strong>CPU</strong> 安装路径,
不要直接升级已有的 FunASR 或 vLLM 服务环境。torch 与 torchaudio 必须匹配,
因为原生特征提取器使用 <code>torchaudio.compliance.kaldi.fbank</code>。</p>
<pre id="code-0"><code class="language-bash">python3.12 -m venv .venv-funasr-native
. .venv-funasr-native/bin/activate
python -m pip install --index-url https://download.pytorch.org/whl/cpu \
'torch==2.10.0+cpu' 'torchaudio==2.10.0+cpu'
python -m pip install 'numpy==1.26.4' 'librosa==0.11.0' 'soundfile==0.13.1' \
'huggingface-hub==1.30.0' 'tokenizers==0.23.2' \
'https://github.com/huggingface/transformers/archive/fc501343edfccdc840eb8594a6cafa8185c2de53.zip'
python -m pip install 'transformers==5.17.0' 'numpy==1.26.4' \
'librosa==0.11.0' 'soundfile==0.13.1' \
'huggingface-hub==1.30.0' 'tokenizers==0.23.2'
python -m pip check
</code></pre>
<p>验证环境安装的是从上述精确提交构建的 wheel。原生特征提取器调用
<code>torchaudio.compliance.kaldi.fbank</code>,因此需要匹配的 <strong>torch 和 torchaudio</strong>。
FunASR 工具包的可选音频依赖策略不能套用到这里。旧环境曾被过旧的 Hub/tokenizers
依赖挡住;不要关闭依赖检查或混搭版本来强行导入。
这是经过验证的环境,不是所有传递依赖的完整锁文件;自己的运行还应记录
<code>python -m pip freeze</code>、平台信息和模型 revision。</p>
<h2 id="先验证预处理不加载权重">先验证预处理,不加载权重</h2>
<p>这一步仅下载公开的配置、tokenizer 和聊天模板,<strong>不下载模型权重</strong>。
一秒合成静音用来检查入口,不是识别质量测试。</p>
<!-- native-example: processor -->
<pre id="code-1"><code class="language-python">import numpy as np
from transformers import AutoProcessor
model_id = "FunAudioLLM/Fun-ASR-Nano-2512-hf"
revision = "d93b302ee7fd505e1b3576120fc142fc6f7820e1"
processor = AutoProcessor.from_pretrained(
model_id, revision=revision, trust_remote_code=False, token=False
)
inputs = processor.apply_transcription_request(
audio=np.zeros(16000, dtype=np.float32),
language="en",
processor_kwargs={
"return_tensors": "pt",
"audio_kwargs": {"sampling_rate": 16000},
},
)
print({name: tuple(value.shape) for name, value in inputs.items()})
</code></pre>
<p>验证环境中文字张量形状是 <code>(1, 42)</code>,音频特征是 <code>(1, 17, 560)</code>,
特征 mask 是 <code>(1, 17)</code>;17 个音频占位 token 与 17 帧有效特征对应。
这些形状随输入时长和模板变化,不应在真实应用里写死。</p>
<h2 id="转写一份录音">转写一份录音</h2>
<p>在工作目录准备非空、<strong>单声道 16 kHz WAV</strong> 文件 <code>audio.wav</code>。
代码明确拒绝其他采样率或声道布局,而不是把任意采样直接标成 16 kHz。
重采样和混音请使用明确的策略,在这一步之前完成,并保留原录音便于回听。</p>
<p>首次加载模型会下载权重,已有固定 revision 缓存时复用缓存。
其内存和耗时明显高于仅预处理。下面显式使用 CPU float32;
GPU 放置、混合精度、attention 后端和服务并发需要分别验证。</p>
<p>运行以下 Python 示例。首次加载需要下载约 1.66 GB 模型权重,然后转写一段
固定版本的官方英文样例。明确使用 CPU float32,不要求 GPU。</p>
<!-- native-example: transcribe -->
<pre id="code-2"><code class="language-python">import soundfile as sf
import torch
<pre id="code-1"><code class="language-python">import torch
from transformers import AutoModelForSpeechSeq2Seq, AutoProcessor
torch.set_num_threads(4)
model_id = "FunAudioLLM/Fun-ASR-Nano-2512-hf"
revision = "d93b302ee7fd505e1b3576120fc142fc6f7820e1"
audio, sample_rate = sf.read("audio.wav", dtype="float32")
if sample_rate != 16000 or audio.ndim != 1 or audio.size == 0:
raise ValueError("Use a non-empty mono 16 kHz WAV file")
audio = "https://huggingface.co/FunAudioLLM/Fun-ASR-Nano-2512/resolve/272c57b82523ada6fd87095e955f8e29100979ab/example/en.mp3"
processor = AutoProcessor.from_pretrained(
model_id, revision=revision, trust_remote_code=False, token=False
@@ -250,10 +171,11 @@ model = AutoModelForSpeechSeq2Seq.from_pretrained(
dtype=torch.float32,
).to("cpu").eval()
inputs = processor.apply_transcription_request(
audio=audio, language="zh",
audio=audio, language="en",
processor_kwargs={
"return_tensors": "pt",
"audio_kwargs": {"sampling_rate": sample_rate},
"audio_kwargs": {"sampling_rate": 16000},
"text_kwargs": {"padding": True},
},
)
with torch.inference_mode():
@@ -261,63 +183,118 @@ with torch.inference_mode():
new_tokens = generated[:, inputs.input_ids.shape[1]:]
print(processor.batch_decode(new_tokens, skip_special_tokens=True)[0])
</code></pre>
<p><code>generated</code> 包含输入 prompt。解码前去掉 <code>inputs.input_ids.shape[1]</code>,
避免把提示模板当作识别结果。<code>max_new_tokens=128</code> 限定这份短文件示例的生成上限;
触顶可能截断输出,调大也不保证整段覆盖。对应语言可改为 <code>language="en"</code> 或
<code>language="ja"</code>;这里是转写语言指令,不是翻译能力承诺。</p>
<h2 id="上下文热词和批处理">上下文、热词和批处理</h2>
<p><code>apply_transcription_request</code> 使用 <code>prompt</code> 传上下文、<code>keywords</code> 传热词,
不是工具包的 <code>hotword</code> 参数或 vLLM HTTP 字段。源码 API 接受全批统一语言,
或与批大小一致的语言列表;逐录音的 prompt 和嵌套关键词列表也必须与批大小匹配。
结果应保持输入顺序。</p>
<p>模板接收了关键词,不等于识别更准确。应在获授权且有代表性的录音中检查专名、
数字和生僻词。把单文件示例变成生产批处理之前,应一起测试 padding、内存和生成文本,
而不是只检查请求张量的形状。</p>
<h2 id="验证范围与边界">验证范围与边界</h2>
<p>本指南的单录音代码还实际运行了官方中文样本,随后测试了英文单录音、中文关键词请求及
中英混合批量。各请求均返回非空文本,并在 128 token 上限之前生成 EOS。
这只是两份公开短样本的功能检查,不是 CER/WER 或容量评测。
CPU 为 Intel Xeon Platinum 8480+,float32、Torch 四线程;torch/torchaudio
2.10.0+cpu、librosa 0.11.0。模型来自先前下载的官方缓存,本轮重新检查了 SHA 和文件大小。</p>
<p>样本来自原始模型的<a href="https://huggingface.co/FunAudioLLM/Fun-ASR-Nano-2512/tree/272c57b82523ada6fd87095e955f8e29100979ab/example">固定 example 目录</a>,
不是假定存在的 -hf 示例目录。中文源文件是单声道 48 kHz MP3,先用 librosa 默认的
soxr_hq 明确重采样,再写成 float32 16 kHz WAV,运行未改写的指南代码。
原始文本为 <code>开饭时间早上九点至下午五点。</code>;传入候选关键词 <code>开放时间</code> 也没有强制产生该词形。
热词是提示,不是强制词表约束。</p>
<p>合成处理器测试覆盖了语言别名、上下文/关键词列表和不同长度的批量输入。
空列表仍会在上游预期校验前抛 <code>IndexError</code>,应用应提前拒绝空批量;指南已显式拒绝空波形,
不经过这一路径。成功用例不能抹去这个限制。最初的重采样也暴露出 librosa 0.10.1
依赖已移除的 <code>pkg_resources</code>;最终环境使用 0.11.0 并重新验证。</p>
<p>2026-09-09 的独立 CPU 验证通过依赖检查、原生配置/类解析和固定官方 revision 的合成预处理。
已安装的配置、模型、处理器、特征提取器源码逐字节匹配上游合并提交。
预处理通过<strong>不代表准确率或容量结论</strong>,也不证明字级时间戳、说话人分离、实时行为、
GPU 兼容性或与 vLLM 的性能一致。</p>
<p>需要匿名说话人与段级时间戳时,参考第三方 OpenMOSS 的
<a href="https://www.funasr.com/docs/moss-transcribe-diarize.html">MOSS 指南</a>;其他路径见
<a href="https://www.funasr.com/docs/model-zoo.html">Model Zoo</a>。不能从“返回了文本”推导时间戳或身份识别能力。
应用验收应保留输入散列、固定版本、原始输出和获授权的人工回听记录;
不要把私有录音或凭据附到公开 issue 中。</p>
<h2 id="来源与下一步">来源与下一步</h2>
<ul>
<li><a href="https://github.com/huggingface/transformers/blob/fc501343edfccdc840eb8594a6cafa8185c2de53/docs/source/en/model_doc/fun_asr_nano.md">合并后的实现与官方用法</a>。</li>
<li><a href="https://github.com/huggingface/transformers/blob/fc501343edfccdc840eb8594a6cafa8185c2de53/src/transformers/models/fun_asr_nano/processing_fun_asr_nano.py">原生处理器</a>与<a href="https://github.com/huggingface/transformers/blob/fc501343edfccdc840eb8594a6cafa8185c2de53/src/transformers/models/fun_asr_nano/feature_extraction_fun_asr_nano.py">音频特征提取器</a>。</li>
<li><a href="https://www.funasr.com/blog/fun-asr-nano-transformers.html">为什么 checkpoint 后缀重要</a>:面向应用的专题解读。</li>
<li><a href="https://github.com/QwenAudio/Fun-ASR">Fun-ASR 模型项目</a>与<a href="https://github.com/modelscope/FunASR">FunASR 工具包</a>。</li>
</ul></article>
<p>模型输出同时包含输入提示和生成结果,因此解码前需要去掉完整输入张量宽度。
这段音频实测的原始输出为:
“The tribal chieftain called for the boy, and presented him with fifty pieces of gold.”
这是功能示例,不是质量保证。</p>
<h2 id="换成自己的录音再做批处理">换成自己的录音,再做批处理</h2>
<p><a href="https://github.com/QwenAudio/Fun-ASR/tree/main/examples/transformers">命令行示例</a>
补齐了输入校验、采样率转换和生成完成检查。克隆 <strong>QwenAudio/Fun-ASR 代码仓库</strong>
(不是 HF 权重仓库),按该目录说明安装独立依赖,再在代码仓库根目录运行:</p>
<pre id="code-2"><code class="language-bash">python examples/transformers/transcribe.py recording.wav --language zh --keywords 开放时间
python examples/transformers/transcribe.py chinese.wav english.wav --language zh en
</code></pre>
<p>示例将多声道取均值为单声道,再用 <code>soxr_hq</code> 显式重采样到 16 kHz,
不会覆盖原始录音。接受 1-4 个文件,总音频时长最多 60 秒;过长、空输入
和非有限采样值会被拒绝,不会静默截断。</p>
<p>在自己的应用中,可向 <code>processor.apply_transcription_request</code> 传入波形、
本地路径或支持的 URL。原始数组必须使用真实采样率,不能把 48 kHz 数组标成
16 kHz。语言使用 <code>zh</code>、<code>en</code> 或 <code>ja</code>。批量时传入音频列表、对应语言列表,
并设置 <code>text_kwargs={"padding": True}</code>,解码后保留输入顺序。</p>
<p><code>keywords</code> 是词汇提示,<code>prompt</code> 是上下文,不是强制词典,也不是工具库的
<code>hotword</code> 参数。中文样例加入 <code>开放时间</code> 后,实测仍输出 <code>开饭时间</code>;
需要用代表性录音和人工参考文本评估质量。</p>
<p>上面的短样例最多生成 128 个新 token。没有 EOS 可能意味着截断,单纯提高
上限不等于长录音已完整覆盖。CLI 输出 <code>reached_eos</code>,缺少 EOS 或文本为空时
以非零状态结束;出现 EOS 也不代表每个字都识别正确。</p>
<h2 id="从示例走向服务">从示例走向服务</h2>
<table>
<thead>
<tr>
<th>需求</th>
<th>checkpoint 与接口</th>
</tr>
</thead>
<tbody>
<tr>
<td>Python 原生 Transformers</td>
<td><code>FunAudioLLM/Fun-ASR-Nano-2512-hf</code>,<code>AutoProcessor</code> + <code>AutoModelForSpeechSeq2Seq</code></td>
</tr>
<tr>
<td>FunASR 流水线和 HTTP 适配器</td>
<td><code>FunAudioLLM/Fun-ASR-Nano-2512</code>,<code>funasr.AutoModel</code>;<a href="https://www.funasr.com/docs/deployment-matrix.html">部署矩阵</a></td>
</tr>
<tr>
<td>原生 vLLM</td>
<td><code>FunAudioLLM/Fun-ASR-Nano-2512-vllm</code>;<a href="https://www.funasr.com/docs/official-native-vllm.html">原生 vLLM 指南</a></td>
</tr>
<tr>
<td>C++ / 边缘部署</td>
<td>转换后的 GGUF;<a href="https://github.com/modelscope/FunASR/blob/main/runtime/llama.cpp/README.md">llama.cpp</a></td>
</tr>
</tbody>
</table>
<p>这些是不同格式,不能只替换模型 ID。Transformers 原生支持不自动提供 HTTP
服务、队列、流式协议、字级时间戳或说话人身份。该原生导出不包含 CTC 时间戳
分支。基础 Nano 支持中、英、日及中文方言、口音;<strong>31 语言 MLT 是独立 checkpoint</strong>。</p>
<p>需要转写、匿名说话人和片段时间戳时,查看第三方 OpenMOSS
<a href="https://www.funasr.com/docs/moss-transcribe-diarize.html">MOSS 指南</a>;其他任务见
<a href="https://www.funasr.com/docs/model-zoo.html">Model Zoo</a>。GPU dtype、attention 后端、显存、
并发和质量都要在实际目标硬件上另行验证。</p>
<h2 id="不加载权重的排查方法">不加载权重的排查方法</h2>
<p>加载失败时,先检查当前解释器、<code>transformers.__version__</code>、<code>-hf</code> 模型 ID
和 revision。5.16.1 不包含此模型,请在新环境升级,不要改动无关运行服务。
原生类位于 <code>transformers.models.fun_asr_nano</code>。</p>
<p>下面是可选的合成静音预处理检查,只下载 processor,不加载模型权重:</p>
<!-- native-example: processor -->
<pre id="code-3"><code class="language-python">import numpy as np
from transformers import AutoProcessor
model_id = "FunAudioLLM/Fun-ASR-Nano-2512-hf"
revision = "d93b302ee7fd505e1b3576120fc142fc6f7820e1"
processor = AutoProcessor.from_pretrained(
model_id, revision=revision, trust_remote_code=False, token=False
)
inputs = processor.apply_transcription_request(
audio=np.zeros(16000, dtype=np.float32), language="en",
processor_kwargs={
"return_tensors": "pt",
"audio_kwargs": {"sampling_rate": 16000},
},
)
print({name: tuple(value.shape) for name, value in inputs.items()})
</code></pre>
<p>应用层先拒绝空录音和空批次。预处理成功<strong>不代表准确率或容量验证</strong>。</p>
<h2 id="复现记录与来源">复现记录与来源</h2>
<p><strong>2026-09-09</strong> 使用实际发布的 5.17.0 wheel 验证:Python 3.12.3,
torch/torchaudio 2.10.0+cpu、float32、四个 Torch 线程,CPU 为
Intel Xeon Platinum 8480+。官方英文 URL、中文波形、中文热词和中英 padding
批次均返回非空文本,并在 128 token 之前出现 EOS。两段公开短样例的功能
检查不等于 CER/WER、GPU 兼容性或服务容量评测。</p>
<p>公开原生 revision 为 <code>d93b302ee7fd505e1b3576120fc142fc6f7820e1</code>,
解析到 <code>FunAsrNanoForConditionalGeneration</code>,使用
<code>trust_remote_code=False</code>。<code>model.safetensors</code> 大小 1,659,773,320 字节,
SHA256:<code>1bbb6dcc5d8b75084a399d48c4d4b0f3aa1d3f09f2616ae40ed2c4fba03d89c9</code>。
音频来自原始模型仓库的
<a href="https://huggingface.co/FunAudioLLM/Fun-ASR-Nano-2512/tree/272c57b82523ada6fd87095e955f8e29100979ab/example">固定样例目录</a>,
不是虚构的 <code>-hf/example</code> 路径。</p>
<p><a href="https://github.com/huggingface/transformers/pull/46180">PR #46180</a> 的合并提交为
<code>fc501343edfccdc840eb8594a6cafa8185c2de53</code>,早于正式包发布。旧版源码安装说明
对应那个时间窗口;现在新安装应使用上面的正式包。
参阅 <a href="https://huggingface.co/docs/transformers/v5.17.0/en/model_doc/fun_asr_nano">5.17.0 官方模型文档</a>
与 <a href="https://huggingface.co/FunAudioLLM/Fun-ASR-Nano-2512-hf">原生 model card</a>。</p>
<p>评估应用时保留版本、输入摘要与原始结果,不要向公开 issue 上传私人录音或凭证。</p></article>
<nav aria-label="相邻文档" class="docs-next">
<a href="https://www.funasr.com/docs/installation.html">安装与环境验证 →</a> </nav>
</div>
<aside class="docs-toc"><strong>本页目录</strong><div class="toc">
<ul>
<li><a href="#用原生-transformers-接入-fun-asr-nano">用原生 Transformers 接入 Fun-ASR-Nano</a><ul>
<li><a href="#合入主线不等于已经发布">合入主线,不等于已经发布</a></li>
<li><a href="#模型格式和接口一起选">模型格式和接口一起选</a></li>
<li><a href="#准备独立的-cpu-环境">准备独立的 CPU 环境</a></li>
<li><a href="#先验证预处理不加载权重">先验证预处理,不加载权重</a></li>
<li><a href="#转写一份录音">转写一份录音</a></li>
<li><a href="#上下文热词和批处理">上下文、热词和批处理</a></li>
<li><a href="#验证范围与边界">验证范围与边界</a></li>
<li><a href="#来源与下一步">来源与下一步</a></li>
<li><a href="#用-transformers-转写-fun-asr-nano">用 Transformers 转写 Fun-ASR-Nano</a><ul>
<li><a href="#先得到第一条转写">先得到第一条转写</a></li>
<li><a href="#换成自己的录音再做批处理">换成自己的录音,再做批处理</a></li>
<li><a href="#从示例走向服务">从示例走向服务</a></li>
<li><a href="#不加载权重的排查方法">不加载权重的排查方法</a></li>
<li><a href="#复现记录与来源">复现记录与来源</a></li>
</ul>
</li>
</ul>
+1 -1
View File
@@ -56,6 +56,7 @@
<details open="">
<summary>开始使用</summary>
<nav aria-label="开始使用">
<a href="https://www.funasr.com/docs/native-transformers.html">Transformers 快速开始</a>
<a href="https://www.funasr.com/docs/installation.html">安装与环境验证</a>
<a href="https://www.funasr.com/docs/quickstart.html">第一次转写</a>
<a href="https://www.funasr.com/docs/python-api.html">Python SDK: AutoModel</a>
@@ -67,7 +68,6 @@
<details open="">
<summary>模型与能力</summary>
<nav aria-label="模型与能力">
<a href="https://www.funasr.com/docs/native-transformers.html">Transformers 原生 Fun-ASR-Nano</a>
<a href="https://www.funasr.com/docs/moss-transcribe-diarize.html">MOSS 转写与说话人分离</a>
<a href="https://www.funasr.com/docs/model-zoo.html">Model Zoo</a>
<a href="https://www.funasr.com/docs/streaming-vad.html">流式语音活动检测</a>
+4 -1
View File
@@ -56,6 +56,7 @@
<details open="">
<summary>开始使用</summary>
<nav aria-label="开始使用">
<a href="https://www.funasr.com/docs/native-transformers.html">Transformers 快速开始</a>
<a href="https://www.funasr.com/docs/installation.html">安装与环境验证</a>
<a aria-current="page" href="https://www.funasr.com/docs/quickstart.html">第一次转写</a>
<a href="https://www.funasr.com/docs/python-api.html">Python SDK: AutoModel</a>
@@ -67,7 +68,6 @@
<details open="">
<summary>模型与能力</summary>
<nav aria-label="模型与能力">
<a href="https://www.funasr.com/docs/native-transformers.html">Transformers 原生 Fun-ASR-Nano</a>
<a href="https://www.funasr.com/docs/moss-transcribe-diarize.html">MOSS 转写与说话人分离</a>
<a href="https://www.funasr.com/docs/model-zoo.html">Model Zoo</a>
<a href="https://www.funasr.com/docs/streaming-vad.html">流式语音活动检测</a>
@@ -133,6 +133,9 @@
<header class="docs-title"><h1>第一次转写</h1><a class="source-link" data-source-link="" href="https://github.com/modelscope/FunASR/blob/main/docs/tutorial/README_zh.md">查看 / 编辑源文档 ↗</a></header>
<article class="docs-article"><p>(简体中文 | <a href="https://www.funasr.com/en/docs/quickstart.html">English</a>)</p>
<div class="source-title-anchor" id="python-sdk-教程"></div>
<blockquote>
<p><strong>只需 Fun-ASR-Nano 原生推理?</strong> 使用 <a href="https://www.funasr.com/docs/native-transformers.html">Transformers 5.17.0 快速开始</a>。它加载独立的 <code>-hf</code> 权重,不要求 FunASR 工具库。本页保留 <code>funasr.AutoModel</code> 工具库路径,两者的依赖、参数和输出不可混用。</p>
</blockquote>
<p>先完成<a href="https://www.funasr.com/docs/installation.html">安装与环境验证</a>。本页按首次转写、结果检查、VAD、批处理、模型专属选项的顺序介绍。模型选择、语言、依赖和模型卡请查阅<a href="https://www.funasr.com/docs/model-zoo.html">模型仓库</a>,不要将某个示例当成所有模型的通用能力。尚未配置本地环境时,可先看 <a href="https://github.com/modelscope/FunASR/blob/main/examples/colab/README_zh.md">Colab 快速体验</a>。</p>
<p>FunASR 软件采用 <a href="https://github.com/modelscope/FunASR/blob/main/LICENSE">MIT 许可</a>。每个模型权重都有各自的许可:请记录完整模型 ID 与 revision,并以对应模型卡为准。只有模型卡明确链接 <a href="https://github.com/modelscope/FunASR/blob/main/MODEL_LICENSE">FunASR 模型许可协议</a> 时,该协议才适用。第三方集成仍属于第三方模型,例如 MOSS-Transcribe-Diarize 来自 OpenMOSS,不是 FunASR 训练的权重。</p>
<p><a id="模型推理" name="模型推理"></a></p>
+1 -1
View File
@@ -56,6 +56,7 @@
<details open="">
<summary>开始使用</summary>
<nav aria-label="开始使用">
<a href="https://www.funasr.com/docs/native-transformers.html">Transformers 快速开始</a>
<a href="https://www.funasr.com/docs/installation.html">安装与环境验证</a>
<a href="https://www.funasr.com/docs/quickstart.html">第一次转写</a>
<a href="https://www.funasr.com/docs/python-api.html">Python SDK: AutoModel</a>
@@ -67,7 +68,6 @@
<details open="">
<summary>模型与能力</summary>
<nav aria-label="模型与能力">
<a href="https://www.funasr.com/docs/native-transformers.html">Transformers 原生 Fun-ASR-Nano</a>
<a href="https://www.funasr.com/docs/moss-transcribe-diarize.html">MOSS 转写与说话人分离</a>
<a href="https://www.funasr.com/docs/model-zoo.html">Model Zoo</a>
<a href="https://www.funasr.com/docs/streaming-vad.html">流式语音活动检测</a>