Skip to main content

FASR: Fast Automatic Speech Recognition Pipeline

Project description

fasr

Fast Automatic Speech Recognition — 工业级 Python 语音识别推理库,源于 FunASR,专注推理性能。

安装

pip install fasr

固定安装当前版本(0.4.0):

pip install "fasr==0.4.0"

快速开始

fasr 的模型能力通过流水线插件提供,需要先安装对应的插件包:

pip install fasr-vad-marblenet fasr-asr-qwen3
import fasr
from fasr import AudioPipeline

# 加载流水线(首次运行会自动下载模型权重)
asr = (
    AudioPipeline()
    .add_pipe("detector", model="marblenet")
    .add_pipe("recognizer", model="qwen3_0_6b")
)

# 单条识别
audio = asr("example.wav")
print(audio.text)

# 批次识别
audios = asr.run(["1.wav", "2.wav", "3.wav"])
for audio in audios:
    print(audio.text)

# 流式返回(大批量场景,逐条 yield)
for audio in asr.stream(["1.wav", "2.wav", "3.wav"]):
    print(audio.text)

自定义流水线

from fasr import AudioPipeline

# 组件:端点检测 → 语音识别 → 标点恢复
asr = (
    AudioPipeline()
    .add_pipe("detector", model="marblenet")
    .add_pipe("recognizer", model="qwen3_0_6b")
    .add_pipe("sentencizer")
)

audio = asr("https://example.com/audio.mp3")
for channel in audio.channels:
    print(channel.text)

流水线插件

fasr 通过插件机制加载模型流水线,安装插件包即可使用:

插件 安装 流水线 组件构成 说明
fasr-paraformer pip install fasr-paraformer paraformer FSMN VAD → Paraformer → CT-Transformer 通用中文离线识别,带时间戳
seaco_paraformer FSMN VAD → Seaco-Paraformer → CT-Transformer 支持热词的离线识别
# 通用识别
asr = fasr.load("paraformer")

# 带热词的识别
asr = fasr.load("seaco_paraformer")

实时语音识别服务

fasr 内置 WebSocket 实时语音识别服务:

# 启动服务
pip install fasr[serve]
fasr serve online --port 27000

支持参数:

参数 默认值 说明
--asr-model stream_paraformer.torch 流式 ASR 模型
--vad-model stream_fsmn.torch 流式 VAD 模型
--vad-chunk-size-ms 100 VAD chunk 大小 (ms)
--vad-end-silence-ms 500 最大结束静音时间 (ms)
--punc-model None 标点恢复模型
--device 自动检测 cpu / cuda / mps

CLI 工具

# 基准测试
fasr benchmark pipeline <name> --input data/ --batch-size 4
fasr benchmark vad --urls data/ --model fsmn
fasr benchmark asr --urls data/ --model paraformer

# 流式测试(支持麦克风交互模式)
fasr benchmark stream_vad --model stream_fsmn.torch --interactive
fasr benchmark stream_asr --model stream_paraformer.torch --interactive

性能对比

测试环境:CPU Intel Xeon Silver 4210 @ 2.20GHz (2核),GPU RTX 6000

完整流水线 (VAD → ASR → Punc)

场景 FunASR fasr 加速比
双通道音频 368.8s (46x) 153.9s (111x) 2.4x
单通道音频 123.8s (22x) 59.0s (46x) 2.1x
AISHELL 123.8s (19x) 59.0s (33x) 1.8x

VAD 单项

场景 FunASR fasr 加速比
双通道音频 219.8s (78x) 86.3s (198x) 2.6x
单通道音频 59.3s (46x) 36.8s (74x) 1.6x

Project details


Download files

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

Source Distribution

fasr-0.4.0.tar.gz (8.7 MB view details)

Uploaded Source

Built Distribution

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

fasr-0.4.0-py3-none-any.whl (4.4 MB view details)

Uploaded Python 3

File details

Details for the file fasr-0.4.0.tar.gz.

File metadata

  • Download URL: fasr-0.4.0.tar.gz
  • Upload date:
  • Size: 8.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.11 {"installer":{"name":"uv","version":"0.10.11","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"22.04","id":"jammy","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-0.4.0.tar.gz
Algorithm Hash digest
SHA256 7292ad9c02f5f7f8aed63ec4674c05c056698703f7b128449ec985a19c1b5779
MD5 d8d295d27abec5b0042e8c74e9e56889
BLAKE2b-256 c7b7c49b56f7ee0a591b5d28004580b14bfdcf895b0fff02d85eeddabafbc8ca

See more details on using hashes here.

File details

Details for the file fasr-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: fasr-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 4.4 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.11 {"installer":{"name":"uv","version":"0.10.11","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"22.04","id":"jammy","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-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 36c10d366b934cd5b8ad75bcfb09a05d3057a09131b717a8db6daf499bf62c2f
MD5 1af36cecab6311bc54d1169f1189f2ae
BLAKE2b-256 08d491f6a477debfd5635ff89942fb57061523ffdc7f568b1ae61b49164544e1

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