Spaces:
Sleeping
Sleeping
| 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() | |