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

单独使用模型

模型实例化时会自动执行 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", "语音识别"]

依赖

  • 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.5.1.tar.gz (6.1 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.5.1-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: fasr_asr_paraformer-0.5.1.tar.gz
  • Upload date:
  • Size: 6.1 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.5.1.tar.gz
Algorithm Hash digest
SHA256 e7c5c604a9e31b9a5585c007b1f1a91a83f4c361c34a27007012a025c6cc2b4b
MD5 75b915c48443cd60f10a8c3373059fcf
BLAKE2b-256 cbefc56b1f57848e71b423bf64d426746c10594865024e2f675cb105b9b51951

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fasr_asr_paraformer-0.5.1-py3-none-any.whl
  • Upload date:
  • Size: 8.5 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.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 cefb347c8cb3c1d90867b9c01e4ca125ff9ae2da197bc3ac72d54439926c365b
MD5 9412218afc2e0170b3d40d80b2f7ba8b
BLAKE2b-256 5cf2bba572ff5fe2e1deff9b2492d170d0da3dec6397de727a57464e17d9b910

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