Skip to main content

Fun ASR model for fasr

Project description

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

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fasr_asr_funasr-0.5.7-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file fasr_asr_funasr-0.5.7-py3-none-any.whl.

File metadata

File hashes

Hashes for fasr_asr_funasr-0.5.7-py3-none-any.whl
Algorithm Hash digest
SHA256 cb7482aecac5b450399e09bd2eaee5217566fa5765f58bc01422926bf0c4ba3d
MD5 b6dac91aac63524a102dfebeaa8f61a7
BLAKE2b-256 7731b64289ef16f8690bd54e2f43050beec6f19eeda341b062b4d74cac803d4e

See more details on using hashes here.

Supported by

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