File size: 1,220 Bytes
0b41e68
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 summary_tool.service import SummaryService


service = SummaryService()


def summarize_text(text, style, max_words):
    return service.summarize(text, style, int(max_words))


with gr.Blocks(
    title="Text Summarizer CPU",
    theme=gr.themes.Soft(primary_hue="blue", secondary_hue="green"),
) as demo:
    gr.Markdown(
        """
        # Text Summarizer CPU
        Paste long text and generate a short AI summary on free CPU.
        """
    )

    text_input = gr.Textbox(label="Input Text", lines=12, placeholder="Paste article, notes, or long text here")
    style_input = gr.Dropdown(
        choices=["Short", "Balanced", "Detailed", "Bullet Points"],
        value="Balanced",
        label="Summary Style",
    )
    max_words_input = gr.Slider(40, 240, value=120, step=10, label="Max Words")
    run_button = gr.Button("Summarize", variant="primary")

    summary_output = gr.Textbox(label="Summary", lines=8)
    status_output = gr.Textbox(label="Status", lines=2)

    run_button.click(
        fn=summarize_text,
        inputs=[text_input, style_input, max_words_input],
        outputs=[summary_output, status_output],
    )


if __name__ == "__main__":
    demo.launch()