Skip to main content

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", "语音识别"])

单独使用模型

from fasr.config import registry

model = registry.asr_models.get("paraformer")()
model.from_checkpoint()

tokens = model.transcribe([waveform_array], sample_rate=16000)
for tok in tokens[0]:
    print(f"{tok.text} [{tok.start_ms}-{tok.end_ms}ms]")

from_checkpoint 参数

ParaformerForASR(paraformer

参数 类型 默认值 说明
checkpoint_dir str | Path | None None(自动下载) 模型权重目录
disable_update bool True 禁用 FunASR 自动更新检查
disable_log bool True 禁用 FunASR 日志输出
disable_pbar bool True 禁用进度条

SeacoParaformerForASR(seaco_paraformer

参数与 ParaformerForASR 相同。

额外 **kwargs 会直接传递给 funasr.AutoModel()

transcribe 额外参数

参数 说明
sample_rate 输入音频采样率,默认 16000
hotwords(仅 seaco) 热词列表,如 ["Paraformer", "语音识别"]

依赖

  • fasr
  • funasrfunasr-onnx
  • torchtorchaudio
  • 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_paraformer-0.3.9.tar.gz (4.5 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_paraformer-0.3.9-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: fasr_asr_paraformer-0.3.9.tar.gz
  • Upload date:
  • Size: 4.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

Hashes for fasr_asr_paraformer-0.3.9.tar.gz
Algorithm Hash digest
SHA256 75093113a42c88c699eabc19e703486b5f15a5e4e43b79459212a348ba081d8b
MD5 f8a5eded4819adca9febfadc73d23305
BLAKE2b-256 9a3c99a854d6ad0ba7a1cc762dfbe7bbf7a8037f8e49f3b23bca4175f49fbb6f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fasr_asr_paraformer-0.3.9-py3-none-any.whl
  • Upload date:
  • Size: 6.8 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_paraformer-0.3.9-py3-none-any.whl
Algorithm Hash digest
SHA256 e56879061b82b6b47966f2e51fd4f575479cee0b7c9870d8627ac2e96f0609a4
MD5 22ad91300d741cec74059b779e2905a9
BLAKE2b-256 1eef23479fa8e26a359eaa29adeac8351f107d5e4945f0abca0154fc814e0234

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