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.4.0.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.4.0-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: fasr_asr_paraformer-0.4.0.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.4.0.tar.gz
Algorithm Hash digest
SHA256 32de6d6d8558d914c853b2691f8752c987a22505af142513b683b1c57c2a7231
MD5 d480e56d5349aac9369f13c8dfec190d
BLAKE2b-256 6f3d70535528c76404bea8d67e97862e9d7034536a89ddbd26e81b004df4aa48

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fasr_asr_paraformer-0.4.0-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.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 680a20c33c36d6a5cea6e827ee12aa49685d0cf9155823260991fcbab0b790d1
MD5 3da135a30f8c9394443af4e75812104f
BLAKE2b-256 9ddf196db6079751abe472b9c0c118f72a90bde0b2e0c9f38a0d90177322b91f

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