Skip to main content

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

Metadata

Release files for fasr-punc-ct-transformer 0.5.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fasr-punc-ct-transformer 0.5.8
File Size Uploaded
fasr_punc_ct_transformer-0.5.8.tar.gz 4.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for fasr-punc-ct-transformer 0.5.8
File Interpreter ABI Platform
fasr_punc_ct_transformer-0.5.8-py3-none-any.whl Python 3 none any Details

Total release size: 9.4 kB

Release files / fasr_punc_ct_transformer-0.5.8.tar.gz

Download URL fasr_punc_ct_transformer-0.5.8.tar.gz
Size 4.0 kB
Tags Source
SHA-256 checksum
How to use checksums
d000291d22ad66f9efc96eb555fcaa49588815163b86f38487ec910616a2c57b
BLAKE2b-256 checksum
How to use checksums
a0c77df5fca6e55242d469cb138c39d9f36eaac7361124a3e5bef72d3382a102
Upload date
Uploaded using Trusted Publishing?
What is 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}

Release files / fasr_punc_ct_transformer-0.5.8-py3-none-any.whl

Download URL fasr_punc_ct_transformer-0.5.8-py3-none-any.whl
Size 5.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8616fe62b14ef2fcacde684ba4b57a9d37941f932c92f256d474c603c4bc1f03
BLAKE2b-256 checksum
How to use checksums
ce1017b95d1268e3d57ac291126e729849b02fc69e084381f4da6280f7e4575a
Upload date
Uploaded using Trusted Publishing?
What is 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}

Release history Release notifications | RSS feed

This release

0.5.8 This release

2 release files

0.5.3

2 release files

0.5.2

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.9

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page