Skip to main content

FASR: Fast Automatic Speech Recognition Pipeline

Project description

fasr

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

安装

pip install fasr

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

pip install "fasr==0.3.9"

快速开始

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

pip install fasr-paraformer
import fasr

# 加载流水线(首次运行会自动下载模型权重)
asr = fasr.load("paraformer")

# 单条识别
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")
    .add_pipe("recognizer")
    .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.3.9.tar.gz (7.6 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.3.9-py3-none-any.whl (4.4 MB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: fasr-0.3.9.tar.gz
  • Upload date:
  • Size: 7.6 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.3.9.tar.gz
Algorithm Hash digest
SHA256 e8300720e43537b20df2387da418116bf3fdfbf995f4806fa1b3bee8ba291c20
MD5 ea0201711b82be4f5d8b06e162da541f
BLAKE2b-256 3ac12500bf877228b941ed38fb8d62772dc9b6b69fccd059d2c8c0a582c03b6d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fasr-0.3.9-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.3.9-py3-none-any.whl
Algorithm Hash digest
SHA256 61cbc5780c4bb43a4e0e9b63121125fdd374042710994f2332bdeb788388e98f
MD5 66a8c0d8d6a8de9dea325e7cf15d3b48
BLAKE2b-256 f5b457695f7399af0d8b45f55ad36ed48cf26fb1d37ab527e21eb245800fd719

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