Skip to main content

FASR: Fast Automatic Speech Recognition Pipeline

Project description

fasr

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

安装

pip install fasr

快速开始

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.7.post2.tar.gz (51.4 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.7.post2-py3-none-any.whl (4.4 MB view details)

Uploaded Python 3

File details

Details for the file fasr-0.3.7.post2.tar.gz.

File metadata

  • Download URL: fasr-0.3.7.post2.tar.gz
  • Upload date:
  • Size: 51.4 MB
  • 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-0.3.7.post2.tar.gz
Algorithm Hash digest
SHA256 91e86624d1e2f8ab61463d4a80465dc0b20c1ad5d9cee6f91ac3d50ca16ee570
MD5 930cfbb9bb73cffdaefc506b1cd9e998
BLAKE2b-256 2ddf0cd2d973a1183bc91a4548288e0cc224247f641ae990e4bdf41920a74531

See more details on using hashes here.

File details

Details for the file fasr-0.3.7.post2-py3-none-any.whl.

File metadata

  • Download URL: fasr-0.3.7.post2-py3-none-any.whl
  • Upload date:
  • Size: 4.4 MB
  • Tags: Python 3
  • 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-0.3.7.post2-py3-none-any.whl
Algorithm Hash digest
SHA256 1996b486d2b43b4b04b1f8e0e0e174a295cf0d3403a24c688b16c16123f5497f
MD5 95a5ef53f3a1259221defc61389859c1
BLAKE2b-256 c0951a762dd34732723beafeae8ef04b0fcebb90b85e9f940aa7caff37ac5cc0

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