Skip to main content

paraformer asr model for fasr

Project description

fasr-asr-paraformer

英文文档地址: README_EN.md

Paraformer 语音识别插件。离线模型返回带时间戳的 token,seaco_paraformer 额外支持热词偏置。

安装

pip install fasr-asr-paraformer

注册模型

注册名 适用场景
paraformer Paraformer 离线 ASR,带 token 时间戳
seaco_paraformer SeacoParaformer 离线 ASR,支持热词
paraformer_online ParaformerOnline 流式 Paraformer ASR

流水线使用

from fasr import AudioPipeline

pipeline = (
    AudioPipeline()
    .add_pipe("detector", model="fsmn")
    .add_pipe(
        "recognizer",
        model="paraformer",
        batch_size=64,
        disable_log=True,
    )
    .add_pipe("sentencizer", model="ct_transformer")
)

热词识别使用 seaco_paraformer

pipeline = (
    AudioPipeline()
    .add_pipe("detector", model="fsmn")
    .add_pipe("recognizer", model="seaco_paraformer")
    .add_pipe("sentencizer", model="ct_transformer")
)

audio = pipeline.run("meeting.wav", hotwords=["Paraformer", "fasr"])[0]

Confection 配置

[asr_model]
@asr_models = "paraformer"
batch_size = 64
device = "cuda:0"
disable_update = true
disable_log = true
disable_pbar = true

放在流水线里:

[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 = "paraformer"
batch_size = 64
device = "cuda:0"
disable_log = true
disable_pbar = true

单独使用

from fasr.config import registry

model = registry.asr_models.get("paraformer")(batch_size=64)
spans = model.transcribe(audio_spans)
for span in spans:
    print(span.text)
    for token in span.tokens or []:
        print(token.text, token.start_ms, token.end_ms)

参数

参数 类型 / 范围 默认值 调高 / 开启时 调低 / 关闭时 什么时候改
batch_size int >= 1 10000 吞吐更高,占用更多内存 内存更省,吞吐更低 批量太慢或内存太高
device str | null null 显式指定设备,例如 cuda:0cpu 如果 CUDA 可用则自动选 cuda:0,否则选 cpu 想覆盖自动设备选择时
disable_update bool True 跳过 FunASR 更新检查 允许检查更新 需要稳定启动或发现更新
disable_log bool True 隐藏后端日志 显示后端日志 调试加载或推理
disable_pbar bool True 隐藏进度条 显示进度条 交互式脚本需要进度
compile_model bool,仅 online False 使用 torch.compile,预热慢但稳态可能更快 无编译预热 长期运行流式服务
chunk_size_ms int,仅 online 600 调用更少,输出更晚 更实时,调度更多 流式延迟/吞吐调优

输出

  • paraformerseaco_paraformer 会填充 span.raw_text
  • 有时间戳时,span.tokens 中的 start_ms / end_ms 是 channel 绝对时间。
  • 如果不传 device,模型会在检测到 CUDA 时自动选 cuda:0, 否则回退到 cpu 并给出提醒日志。
  • seaco_paraformer 可通过 hotwords=[...] 传热词。

依赖

  • 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_paraformer-0.5.7-py3-none-any.whl (10.4 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for fasr_asr_paraformer-0.5.7-py3-none-any.whl
Algorithm Hash digest
SHA256 ae4a8b82a325609dd2218e96e9455908ba89aaa138ff74a321d37d4d336abe63
MD5 cac36c2c85d7de5518a02d0bb05c2d7d
BLAKE2b-256 84e987c04c20f5129ee121570df7f168672921a99503dafc44f833123615cf16

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