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 |
采样温度 |
依赖
fasrtorch >= 2.0.0、torchaudiotransformers >= 4.36librosa >= 0.10.0kaldiio >= 2.18.0、kaldi-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.0.tar.gz
(29.5 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fasr_asr_firered-0.5.0.tar.gz.
File metadata
- Download URL: fasr_asr_firered-0.5.0.tar.gz
- Upload date:
- Size: 29.5 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
321aca19e9de7712a8049e366e892fdbf5ea6224ca9f0c95233cd02f58c84151
|
|
| MD5 |
b95827b66ebc356aed07410115bcfeaa
|
|
| BLAKE2b-256 |
5a846c79600ceb42df0431993ed744a22648eb61c6e9a5a35e80a2989eccde5f
|
File details
Details for the file fasr_asr_firered-0.5.0-py3-none-any.whl.
File metadata
- Download URL: fasr_asr_firered-0.5.0-py3-none-any.whl
- Upload date:
- Size: 36.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c5f86ca3ef499d1f1cc9bd3b6fe9985394171f6569d30a52f5607ff375c382d8
|
|
| MD5 |
d393237511e114d793ddcedc2f49e2e2
|
|
| BLAKE2b-256 |
11aa96fb0abcef7a6edc31a1e48339a57cd28349208ae58496ff9b6370c4f034
|