paraformer asr model for fasr
Project description
fasr-asr-paraformer
基于 Paraformer 的语音识别模型插件,为 fasr 提供离线 ASR 能力,支持带时间戳输出和热词偏置。
安装
pip install fasr-asr-paraformer
注册模型
| 注册名 | 类 | 默认 checkpoint | 说明 |
|---|---|---|---|
paraformer |
ParaformerForASR |
iic/speech_paraformer-large-vad-punc_asr_nat-zh-cn-16k-common-vocab8404-pytorch |
离线 Paraformer,输出带时间戳的 token |
seaco_paraformer |
SeacoParaformerForASR |
iic/speech_seaco_paraformer_large_asr_nat-zh-cn-16k-common-vocab8404-pytorch |
支持热词偏置的 Paraformer |
模型权重默认从 ModelScope 自动下载。
使用方式
在流水线中使用
from fasr import AudioPipeline
# 标准 Paraformer
pipeline = (
AudioPipeline()
.add_pipe("detector", model="fsmn")
.add_pipe("recognizer", model="paraformer")
.add_pipe("sentencizer", model="ct_transformer")
)
audio = pipeline("example.wav")
print(audio.text)
热词识别
pipeline = (
AudioPipeline()
.add_pipe("detector", model="fsmn")
.add_pipe("recognizer", model="seaco_paraformer")
.add_pipe("sentencizer", model="ct_transformer")
)
audio = pipeline("meeting.wav", hotwords=["Paraformer", "语音识别"])
单独使用模型
模型实例化时会自动执行 download_checkpoint() + load_checkpoint():
from fasr.config import registry
model = registry.asr_models.get("paraformer")()
tokens = model.transcribe([waveform_array], sample_rate=16000)
for tok in tokens[0]:
print(f"{tok.text} [{tok.start_ms}-{tok.end_ms}ms]")
# 使用自定义权重目录
model.load_checkpoint("/path/to/custom/paraformer")
运行期 / 会话参数
公共字段(离线 paraformer / seaco_paraformer)
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
checkpoint |
str | None |
子类各自默认 | 远程 repo_id;非空时实例化会自动下载 |
cache_dir |
str | Path | None |
None |
缓存目录,None 使用 fasr.utils.get_cache_dir() |
endpoint |
Literal["modelscope", "huggingface", "hf-mirror"] |
"modelscope" |
下载端点 |
disable_update |
bool |
True |
禁用 FunASR 自动更新检查 |
disable_log |
bool |
True |
禁用 FunASR 日志输出 |
disable_pbar |
bool |
True |
禁用进度条 |
batch_size |
int |
10000 |
推理批次大小 |
transcribe 额外参数
| 参数 | 说明 |
|---|---|
sample_rate |
输入音频采样率,默认 16000 |
hotwords(仅 seaco) |
热词列表,如 ["Paraformer", "语音识别"] |
依赖
fasrfunasr、funasr-onnxtorch、torchaudio- 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
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_paraformer-0.5.0.tar.gz.
File metadata
- Download URL: fasr_asr_paraformer-0.5.0.tar.gz
- Upload date:
- Size: 5.6 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 |
5c57e48638dc2a064ed2321ec1e7c0d76dc60131a17ff9c033d6cb0b992f73db
|
|
| MD5 |
44fb6381922d1f7281f505ea9b54b903
|
|
| BLAKE2b-256 |
8cef221078f1b4b9b314108e142a952d6e3f4ca71af7f9817902515e75deb1ca
|
File details
Details for the file fasr_asr_paraformer-0.5.0-py3-none-any.whl.
File metadata
- Download URL: fasr_asr_paraformer-0.5.0-py3-none-any.whl
- Upload date:
- Size: 8.0 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 |
bfc8d4768f51e9beb5982a585439630572031986b68824867740254852248f75
|
|
| MD5 |
39620cc8a6e3e2a8f780dd60115b8b14
|
|
| BLAKE2b-256 |
a8b2698ce28cfc62de4fa2601ce3e1bcc72cb3945254c885da680fc2645b6cc1
|