Skip to main content

ct-transformer punctuation model for fasr

Project description

fasr-punc-ct-transformer

英文文档地址: README_EN.md

CT-Transformer 标点恢复插件。通常作为 ASR 后面的 sentencizer 阶段,把无标点识别文本切成带标点的 AudioSpan 句子。

安装

pip install fasr-punc-ct-transformer

注册模型

注册名 适用场景
ct_transformer CTTransformerForPunc 中文和中英混合标点恢复

默认 checkpoint 是 iic/punc_ct-transformer_zh-cn-common-vocab272727-pytorch

流水线使用

from fasr import AudioPipeline

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

Confection 配置

[punc_model]
@punc_models = "ct_transformer"
disable_update = true
disable_log = true
disable_pbar = true

放在流水线里:

[pipeline]
@pipelines = "AudioPipeline.v1"
pipe_order = ["sentencizer"]

[pipeline.pipes]

[pipeline.pipes.sentencizer]
@pipes = "thread_pipe"

[pipeline.pipes.sentencizer.component]
@components = "sentencizer"

[pipeline.pipes.sentencizer.component.model]
@punc_models = "ct_transformer"
disable_update = true
disable_log = true
disable_pbar = true

单独使用

from fasr.config import registry

model = registry.punc_models.get("ct_transformer")()
sentences = model.restore("今天天气真好我想出去玩你觉得呢")
for sentence in sentences:
    print(sentence.text)

参数

参数 类型 默认值 true false 什么时候改
disable_update bool True 跳过 FunASR 更新检查 允许检查更新 需要稳定启动或调试更新
disable_log bool True 隐藏后端日志 显示后端日志 调试加载或推理
disable_pbar bool True 隐藏进度条 显示进度条 交互式脚本需要进度

说明

  • restore(text) 返回 AudioSpanList,不是普通字符串。
  • 输入应是已经识别出来的文本;该插件不做 ASR。
  • 流水线中应放在 sentencizer 组件上。

依赖

  • 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.8.tar.gz (4.0 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.8-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: fasr_punc_ct_transformer-0.5.8.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"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.8.tar.gz
Algorithm Hash digest
SHA256 d000291d22ad66f9efc96eb555fcaa49588815163b86f38487ec910616a2c57b
MD5 34e12a6479f2d2b59d0eb9f792c08b1e
BLAKE2b-256 a0c77df5fca6e55242d469cb138c39d9f36eaac7361124a3e5bef72d3382a102

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fasr_punc_ct_transformer-0.5.8-py3-none-any.whl
  • Upload date:
  • Size: 5.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"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.8-py3-none-any.whl
Algorithm Hash digest
SHA256 8616fe62b14ef2fcacde684ba4b57a9d37941f932c92f256d474c603c4bc1f03
MD5 7e0759b18f665f3c4bcbe958807a9d8f
BLAKE2b-256 ce1017b95d1268e3d57ac291126e729849b02fc69e084381f4da6280f7e4575a

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