fasr-asr-paraformer
英文文档地址: README_EN.md
Paraformer 语音识别插件。离线模型返回带时间戳的 token,seaco_paraformer 额外支持热词偏置。
安装
pip install fasr-asr-paraformer
注册模型
| 注册名 | 类 | 适用场景 |
|---|---|---|
paraformer |
Paraformer |
离线 ASR,带 token 时间戳 |
seaco_paraformer |
SeacoParaformer |
离线 ASR,支持热词 |
paraformer_online |
ParaformerOnline |
流式 Paraformer ASR |
流水线使用
from fasr import AudioPipeline
pipeline = (
AudioPipeline()
.add_pipe("detector", model="fsmn")
.add_pipe(
"recognizer",
model="paraformer",
batch_size=64,
disable_log=True,
)
.add_pipe("sentencizer", model="ct_transformer")
)
热词识别使用 seaco_paraformer:
pipeline = (
AudioPipeline()
.add_pipe("detector", model="fsmn")
.add_pipe("recognizer", model="seaco_paraformer")
.add_pipe("sentencizer", model="ct_transformer")
)
audio = pipeline.run("meeting.wav", hotwords=["Paraformer", "fasr"])[0]
Confection 配置
[asr_model]
@asr_models = "paraformer"
batch_size = 64
device = "cuda:0"
disable_update = true
disable_log = true
disable_pbar = true
放在流水线里:
[pipeline]
@pipelines = "AudioPipeline.v1"
pipe_order = ["recognizer"]
[pipeline.pipes]
[pipeline.pipes.recognizer]
@pipes = "thread_pipe"
batch_size = 4
[pipeline.pipes.recognizer.component]
@components = "recognizer"
[pipeline.pipes.recognizer.component.model]
@asr_models = "paraformer"
batch_size = 64
device = "cuda:0"
disable_log = true
disable_pbar = true
单独使用
from fasr.config import registry
model = registry.asr_models.get("paraformer")(batch_size=64)
spans = model.transcribe(audio_spans)
for span in spans:
print(span.text)
for token in span.tokens or []:
print(token.text, token.start_ms, token.end_ms)
参数
| 参数 | 类型 / 范围 | 默认值 | 调高 / 开启时 | 调低 / 关闭时 | 什么时候改 |
|---|---|---|---|---|---|
batch_size |
int >= 1 |
10000 |
吞吐更高,占用更多内存 | 内存更省,吞吐更低 | 批量太慢或内存太高 |
device |
str | null |
null |
显式指定设备,例如 cuda:0 或 cpu |
如果 CUDA 可用则自动选 cuda:0,否则选 cpu |
想覆盖自动设备选择时 |
disable_update |
bool |
True |
跳过 FunASR 更新检查 | 允许检查更新 | 需要稳定启动或发现更新 |
disable_log |
bool |
True |
隐藏后端日志 | 显示后端日志 | 调试加载或推理 |
disable_pbar |
bool |
True |
隐藏进度条 | 显示进度条 | 交互式脚本需要进度 |
compile_model |
bool,仅 online |
False |
使用 torch.compile,预热慢但稳态可能更快 |
无编译预热 | 长期运行流式服务 |
chunk_size_ms |
int,仅 online |
600 |
调用更少,输出更晚 | 更实时,调度更多 | 流式延迟/吞吐调优 |
输出
paraformer和seaco_paraformer会填充span.raw_text。- 有时间戳时,
span.tokens中的start_ms/end_ms是 channel 绝对时间。 - 如果不传
device,模型会在检测到 CUDA 时自动选cuda:0, 否则回退到cpu并给出提醒日志。 seaco_paraformer可通过hotwords=[...]传热词。
依赖
fasrfunasr- Python 3.10-3.12
Metadata
Release files for fasr-asr-paraformer 0.5.8
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| fasr_asr_paraformer-0.5.8.tar.gz | 7.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| fasr_asr_paraformer-0.5.8-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 18.0 kB
Release files / fasr_asr_paraformer-0.5.8.tar.gz
| Download URL | fasr_asr_paraformer-0.5.8.tar.gz |
|---|---|
| Size | 7.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a2054860d3c488b0c60d7916bdf843bcdd1076ac84c48e506c57bf55e8b65dec
|
|
BLAKE2b-256 checksum How to use checksums |
ec146c65739bf531cf63956a31c1d69cdecc9c3fcf87d721bad067b512182866
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / fasr_asr_paraformer-0.5.8-py3-none-any.whl
| Download URL | fasr_asr_paraformer-0.5.8-py3-none-any.whl |
|---|---|
| Size | 10.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
98f803c0df1117f3c8c29cba65c90a67c537da53427c00195c23e1635dc2665a
|
|
BLAKE2b-256 checksum How to use checksums |
e3e69a2ce3212e5e1ca7ba908d14f7f75374f5b851cd0aa7147c305c182f206f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|