Skip to main content

ct-transformer punctuation model for fasr

Project description

fasr-punc-ct-transformer

基于 CT-Transformer 的标点恢复模型插件,为 fasr 提供中英文混合标点恢复能力。

安装

pip install fasr-punc-ct-transformer

注册模型

注册名 默认 checkpoint 说明
ct_transformer CTTransformerForPunc iic/punc_ct-transformer_zh-cn-common-vocab272727-pytorch CT-Transformer 标点恢复,支持中英文混合

模型权重默认从 ModelScope 自动下载。

使用方式

在流水线中使用

标点模型通常作为 sentencizer 组件在流水线末端使用:

from fasr import AudioPipeline

pipeline = (
    AudioPipeline()
    .add_pipe("detector", model="fsmn")
    .add_pipe("recognizer", model="paraformer")
    .add_pipe("sentencizer", model="ct_transformer")
)

单独使用模型

模型实例化时会自动执行 download_checkpoint() + load_checkpoint()

from fasr.config import registry

model = registry.punc_models.get("ct_transformer")()
spans = model.restore("今天天气真好我想出去玩你觉得呢")
for span in spans:
    print(span.text)  # 带标点的句子

# 使用自定义权重目录
model.load_checkpoint("/path/to/custom/ct_transformer")

运行期 / 会话参数

参数 类型 默认值 说明
checkpoint str | None "iic/punc_ct-transformer_zh-cn-common-vocab272727-pytorch" 远程 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 禁用进度条

依赖

  • fasr
  • funasr
  • 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_punc_ct_transformer-0.5.0.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fasr_punc_ct_transformer-0.5.0-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file fasr_punc_ct_transformer-0.5.0.tar.gz.

File metadata

  • Download URL: fasr_punc_ct_transformer-0.5.0.tar.gz
  • Upload date:
  • Size: 3.7 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_punc_ct_transformer-0.5.0.tar.gz
Algorithm Hash digest
SHA256 540ab180bf534d46c0f5b6bcbaba2d65b37b56cf93e864931c7011a884f67b7d
MD5 1c1828af14276e61404f1474ea34bab3
BLAKE2b-256 04df5b68878eb643fb71aa695de04505f7126f3f6eb69ff42bac462a7bf0943f

See more details on using hashes here.

File details

Details for the file fasr_punc_ct_transformer-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: fasr_punc_ct_transformer-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 5.3 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_punc_ct_transformer-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3065752b424319ae85da4eb32df55974ebc4b7c582de1f3b4d3748ed3b28b36e
MD5 9ff012a164cecdbe086f9ab0bff90bcd
BLAKE2b-256 146b91a0fa46f4eafaa913d8e74f7ee4e6277af444c6f269fab4635d2d2aa04e

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