File size: 1,349 Bytes
eac1a45
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import gradio as gr
from cttPunctuator import CttPunctuator

punc = CttPunctuator()


def punctuate(text):
    # 使用模型生成标点润饰的文本
    return punc.punctuate(text)[0]


def clear_text():
    return "", ""


with gr.Blocks() as iface:
    gr.Markdown("""

    # 中英文标点润饰工具



    这个工具可以帮助你自动为文本添加适当的标点符号。

    基于项目:https://github.com/lovemefan/CT-Transformer-punctuation



    使用说明:

    1. 在左侧的输入框中粘贴或输入你的文本。

    2. 点击"润饰"按钮。

    3. 查看右侧输出框中的结果。可以使用输出框右上角复制按钮快速复制结果。

    4. 如需清空所有内容,点击"清空"按钮。

    """)

    with gr.Row():
        with gr.Column(scale=1):
            input_text = gr.Textbox(lines=10, label="输入文本")

        with gr.Column(scale=1):
            output_text = gr.Textbox(lines=10, label="结果", show_copy_button=True)

    with gr.Row():
        punctuate_button = gr.Button("润饰")
        clear_button = gr.Button("清空")

    punctuate_button.click(fn=punctuate, inputs=input_text, outputs=output_text)
    clear_button.click(fn=clear_text, inputs=None, outputs=[input_text, output_text])

# 启动Gradio应用
iface.launch()