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.3.9.tar.gz (28.3 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.3.9-py3-none-any.whl (35.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: fasr_asr_firered-0.3.9.tar.gz
  • Upload date:
  • Size: 28.3 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.3.9.tar.gz
Algorithm Hash digest
SHA256 ce6c33f4bb670ff48ef1c80b0383e979576e084f57c8acc463d47da8be84eae8
MD5 1557094a8a12a13da07cdaa166137a76
BLAKE2b-256 63623d382ff3265a69536b26d7bd9c75e832fc43e4ae68b797f0e3e129272565

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fasr_asr_firered-0.3.9-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.3.9-py3-none-any.whl
Algorithm Hash digest
SHA256 3367c870444a55513baf65b1c12f6236e72e9515ba342a51e500ca620e4f7b0d
MD5 a1b57400899ed7b341a82e0220e33fa5
BLAKE2b-256 6fd93ee3c16229abd2e69df5e329418688fb3f3240415b64ff67a07e53aca097

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