Skip to main content

FireRed ASR for fasr (bundled fireredasr2 inference)

Project description

fasr-asr-firered

基于 FireRedASR2 的语音识别模型插件,为 fasr 提供 AED(CTC + Transformer 解码)和 LLM(语音编码 + 大模型解码)两种推理模式。

安装

pip install fasr-asr-firered

注册模型

注册名 默认 checkpoint 说明
firered / firered_aed FireRedAEDForASR FireRedTeam/FireRedASR2-AED AED 模式,支持时间戳,CTC + Transformer 解码
firered_llm FireRedLLMForASR FireRedTeam/FireRedASR2-LLM LLM 模式,语音编码 + 大模型解码,更高精度

模型权重默认从 ModelScope 自动下载。

使用方式

在流水线中使用

from fasr import AudioPipeline

pipeline = (
    AudioPipeline()
    .add_pipe("detector", model="fsmn")
    .add_pipe("recognizer", model="firered_aed", checkpoint_dir="/path/to/aed-ckpt")
    .add_pipe("sentencizer", model="ct_transformer")
)

audio = pipeline("example.wav")
print(audio.text)

单独使用模型

模型实例化时会自动执行 download_checkpoint() + load_checkpoint()

from fasr.config import registry

# AED 模式(可直接构造字段来覆盖解码参数)
model = registry.asr_models.get("firered_aed")(beam_size=3, return_timestamp=True)
tokens = model.transcribe([waveform_array], sample_rate=16000)

# 使用自定义权重目录
model.load_checkpoint("/path/to/FireRedASR2-AED")

# LLM 模式
model = registry.asr_models.get("firered_llm")(temperature=1.0)
tokens = model.transcribe([waveform_array], sample_rate=16000)

运行期 / 会话参数

公共字段

参数 类型 默认值 说明
checkpoint str | None 子类各自默认 远程 repo_id;非空时实例化会自动下载
cache_dir str | Path | None None 缓存目录,None 使用 fasr.utils.get_cache_dir()
endpoint Literal["modelscope", "huggingface", "hf-mirror"] "modelscope" 下载端点
device str | None None(自动检测 CUDA) 设备,"cpu""cuda"
beam_size int 3 束搜索宽度
decode_max_len int 0 最大解码长度,0 不限制

FireRedAEDForASR(firered / firered_aed

参数 类型 默认值 说明
use_half bool True 是否使用 FP16 推理
nbest int 1 N-best 输出数量
softmax_smoothing float 1.25 Softmax 平滑系数
aed_length_penalty float 0.6 AED 长度惩罚
eos_penalty float 1.0 EOS 惩罚系数
return_timestamp bool True 是否返回字级时间戳
elm_dir str "" 外部语言模型目录
elm_weight float 0.0 外部语言模型权重

FireRedLLMForASR(firered_llm

参数 类型 默认值 说明
decode_min_len int 0 最小解码长度
repetition_penalty float 1.2 重复惩罚系数
llm_length_penalty float 0.0 LLM 长度惩罚
temperature float 1.0 采样温度

依赖

  • fasr
  • torch >= 2.0.0torchaudio
  • transformers >= 4.36
  • librosa >= 0.10.0
  • kaldiio >= 2.18.0kaldi-native-fbank >= 1.19.0
  • 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 Distribution

fasr_asr_firered-0.5.1.tar.gz (29.6 kB view details)

Uploaded Source

Built Distribution

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

fasr_asr_firered-0.5.1-py3-none-any.whl (36.5 kB view details)

Uploaded Python 3

File details

Details for the file fasr_asr_firered-0.5.1.tar.gz.

File metadata

  • Download URL: fasr_asr_firered-0.5.1.tar.gz
  • Upload date:
  • Size: 29.6 kB
  • 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_asr_firered-0.5.1.tar.gz
Algorithm Hash digest
SHA256 5b9a325672b61feb258f13eed41bede187d327058510173db0542df7ba1c29f4
MD5 74f5d8237fa82d5f8a25259d2ee135d5
BLAKE2b-256 dbc9669a5993600f92b481dbb917534af621e0d2b3ab40c6e9662d34ff68dbb9

See more details on using hashes here.

File details

Details for the file fasr_asr_firered-0.5.1-py3-none-any.whl.

File metadata

  • Download URL: fasr_asr_firered-0.5.1-py3-none-any.whl
  • Upload date:
  • Size: 36.5 kB
  • 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_asr_firered-0.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b9e8836b6b2b57b7fb0b0ebce433da4c7cf10a26029cca1bb3ce773a51df368d
MD5 47de84aaea27cf252bad476f510cc0a1
BLAKE2b-256 bd889ed56173a92c5e8e443aa9bff330cef860931fe7df784145a1a3c445d286

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