Skip to main content

fasr-asr-funasr

英文文档地址: README_EN.md

Fun-ASR-Nano 语音识别插件。该插件封装 funasr.AutoModel,把整段识别文本写入 AudioSpan.raw_text,不返回词级或字级时间戳。

安装

pip install fasr-asr-funasr

注册模型

注册名 适用场景
fun_asr_nano FunASRNano 轻量 FunASR 识别,无时间戳输出

默认 checkpoint 是 FunAudioLLM/Fun-ASR-Nano-2512

流水线使用

from fasr import AudioPipeline

pipeline = (
    AudioPipeline()
    .add_pipe("detector", model="fsmn")
    .add_pipe(
        "recognizer",
        model="fun_asr_nano",
        device="cuda:0",
        language="中文",
        itn=True,
    )
    .add_pipe("sentencizer", model="ct_transformer")
)
目标 写法 效果
CPU 推理 device="cpu" 不依赖 CUDA,但通常更慢
使用第一张 GPU device="cuda:0" 使用 GPU 0
关闭数字/日期规范化 itn=False 保留更接近口语的文本
固定语言提示 language="中文" 把语言标签传给 FunASR

Confection 配置

[asr_model]
@asr_models = "fun_asr_nano"
device = "cuda:0"
language = "中文"
itn = true
batch_size = 1

放在流水线里:

[pipeline]
@pipelines = "AudioPipeline.v1"
pipe_order = ["recognizer"]

[pipeline.pipes]

[pipeline.pipes.recognizer]
@pipes = "thread_pipe"
batch_size = 4

[pipeline.pipes.recognizer.component]
@components = "recognizer"

[pipeline.pipes.recognizer.component.model]
@asr_models = "fun_asr_nano"
device = "cuda:0"
language = "中文"
itn = true
batch_size = 1

单独使用

from fasr.config import registry

model = registry.asr_models.get("fun_asr_nano")()
model.device = "cuda:0"

spans = model.transcribe(audio_spans, hotwords=["fasr"], language="中文")
for span in spans:
    print(span.text)

使用本地权重:

model.load_checkpoint("/path/to/Fun-ASR-Nano")

参数

参数 类型 / 范围 默认值 调高 / 开启时 调低 / 关闭时 什么时候改
device str "cuda:0" 选择 CUDA 设备,如 "cuda:1" "cpu" 使用 CPU 部署设备变化
language str "中文" 更强语言提示 换成其它支持的语言标签 已知音频语言
itn bool True 规范化数字、日期等 保留较原始文本 需要口语形式输出
batch_size int >= 1 1 吞吐更高,占用更多内存 内存更省,吞吐更低 批量推理调优
trust_remote_code bool True 允许加载 checkpoint 自定义代码 更安全,但部分模型可能加载失败 使用不可信 checkpoint

输出

  • 写入 span.raw_text
  • 不填充 span.tokens,因为 Fun-ASR-Nano 不返回时间戳。
  • 读取 span.text 即可得到识别文本。

依赖

  • fasr
  • funasr
  • Python 3.10-3.12

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fasr_asr_funasr-0.5.8.tar.gz (6.5 kB view details)

Uploaded Source

File details

Details for the file fasr_asr_funasr-0.5.8.tar.gz.

File metadata

  • Download URL: fasr_asr_funasr-0.5.8.tar.gz
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for fasr_asr_funasr-0.5.8.tar.gz
Algorithm Hash digest
SHA256 a12f856797e8ec86b238b716af2ea2402a901789c91e93942a973581c38726cb
MD5 1bf5c804a8ff5006fca312a270a4ed2e
BLAKE2b-256 24acea5499a673f5117df6e07494aa7fffaeac0e566bb8cbc98c19f7db00d270

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.5.8 This release

1 file

0.5.7

1 file

0.5.3

2 files

0.5.2

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page