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)

单独使用模型

from fasr.config import registry

# AED 模式
model = registry.asr_models.get("firered_aed")()
model.from_checkpoint(
    checkpoint_dir="/path/to/FireRedASR2-AED",
    beam_size=3,
    return_timestamp=True,
)
tokens = model.transcribe([waveform_array], sample_rate=16000)

# LLM 模式
model = registry.asr_models.get("firered_llm")()
model.from_checkpoint(checkpoint_dir="/path/to/FireRedASR2-LLM")
tokens = model.transcribe([waveform_array], sample_rate=16000)

from_checkpoint 参数

FireRedAEDForASR(firered / firered_aed

参数 类型 默认值 说明
checkpoint_dir str | Path | None None(自动下载) 模型权重目录
device str | None None(自动检测 CUDA) 设备,"cpu""cuda"
use_half bool True 是否使用 FP16 推理
beam_size int 3 束搜索宽度
nbest int 1 N-best 输出数量
decode_max_len int 0 最大解码长度,0 为不限制
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

参数 类型 默认值 说明
checkpoint_dir str | Path | None None(自动下载) 模型权重目录
device str | None None(自动检测 CUDA) 设备,"cpu""cuda"
beam_size int 3 束搜索宽度
decode_max_len int 0 最大解码长度,0 为不限制
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.4.0.tar.gz (28.4 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.4.0-py3-none-any.whl (35.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: fasr_asr_firered-0.4.0.tar.gz
  • Upload date:
  • Size: 28.4 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.4.0.tar.gz
Algorithm Hash digest
SHA256 cae1389f7a8f49f5e1f9da1400d1a8de5f0235535f8320c0874d62e3527cbbad
MD5 8c5aa78f2c9074a3d05724b77072668e
BLAKE2b-256 1f89bf5565e396325049891663c30118e416387a4d58b8a5d8a94f1b9e4f7339

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fasr_asr_firered-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 35.4 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.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 301534286c6f47b15434f9a34bf96bddc441af6e9a14637477d552a434bfa506
MD5 c777b8fed73b9ee29f7422068d97fcf6
BLAKE2b-256 358ccaaa395683899198186aff1fcb23111eba39e20537645127c81658241927

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