Skip to main content

FireRed ASR for fasr (bundled fireredasr2 inference)

Project description

fasr-asr-firered

英文文档地址: README_EN.md

FireRedASR2 语音识别插件,提供 AED 解码和 LLM 解码。AED 可返回 token 时间戳,LLM 更偏向整段文本识别,不返回时间戳。

安装

pip install fasr-asr-firered

注册模型

注册名 适用场景
firered FireRedAEDForASR AED 模式默认别名
firered_aed FireRedAEDForASR 带时间戳 AED 识别
firered_llm FireRedLLMForASR LLM 解码,无时间戳

流水线使用

from fasr import AudioPipeline

pipeline = (
    AudioPipeline()
    .add_pipe("detector", model="fsmn")
    .add_pipe(
        "recognizer",
        model="firered_aed",
        device="cuda",
        beam_size=3,
        return_timestamp=True,
    )
    .add_pipe("sentencizer", model="ct_transformer")
)
目标 写法 效果
需要 token 时间戳 model="firered_aed", return_timestamp=True 填充 span.tokens
只要整段文本 model="firered_llm" 填充 span.raw_text,无时间戳
降低 AED 显存 use_half=True GPU 上 FP16 推理
CPU 推理 device="cpu" 不依赖 CUDA,但更慢
更宽搜索 beam_size=5 可能更准,但更慢

Confection 配置

[asr_model]
@asr_models = "firered_aed"
device = "cuda"
beam_size = 3
return_timestamp = true
use_half = true

放在流水线里:

[pipeline]
@pipelines = "AudioPipeline.v1"
pipe_order = ["recognizer"]

[pipeline.pipes]

[pipeline.pipes.recognizer]
@pipes = "thread_pipe"
batch_size = 2

[pipeline.pipes.recognizer.component]
@components = "recognizer"

[pipeline.pipes.recognizer.component.model]
@asr_models = "firered_aed"
device = "cuda"
beam_size = 3
return_timestamp = true

参数

公共参数

参数 类型 / 范围 默认值 调高 / 开启时 调低 / 关闭时 什么时候改
device strNone None "cuda" 使用 GPU "cpu" 使用 CPU 部署设备变化
beam_size int >= 1 3 搜索更宽,更慢更耗内存 更快,可能精度下降 精度/速度取舍
decode_max_len int >= 0 0 允许更长输出 更短上限;0 交给后端 输出被截断或过长

AED 参数

参数 类型 / 范围 默认值 调高 / 开启时 调低 / 关闭时 什么时候改
use_half bool True 显存更低,GPU 更快 FP32 更稳定 显存或数值稳定性问题
return_timestamp bool True 返回 token 时间戳 只返回文本 是否需要时间戳
nbest int >= 1 1 返回更多候选 只返回最佳结果 需要候选结果
elm_weight float 0.0 外部语言模型影响更强 0.0 关闭外部 LM 提供 elm_dir

LLM 参数

参数 类型 / 范围 默认值 调高时 调低时 什么时候改
decode_min_len int >= 0 0 强制更长最小输出 允许更短输出 输出过早结束
repetition_penalty float 1.2 更强重复抑制 更允许重复 出现重复短语
temperature float >= 0 1.0 更发散 更确定 需要稳定或多样性

输出

  • AED 写入 span.raw_text
  • return_timestamp=True 时 AED 也填充 span.tokens
  • LLM 只写入 span.raw_text

依赖

  • fasr
  • torch >= 2.0.0
  • torchaudio
  • transformers >= 4.36
  • librosa >= 0.10.0
  • kaldiio >= 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 Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

fasr_asr_firered-0.5.7-py3-none-any.whl (37.2 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for fasr_asr_firered-0.5.7-py3-none-any.whl
Algorithm Hash digest
SHA256 cc3b5bdcdc47e182e74537fc5b6806d78fcb9b28e54f835a40ef8f3be96146df
MD5 4be522c275f969f2de10ba7da1da9f23
BLAKE2b-256 c111ecf0a2bea37c45f47022eacb32e19874d9c4886bec04609169bad630ba7c

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