Smart-AI-Tools / text_summary.py
AIROBOHUB's picture
Create text_summary.py
5d9d1d0 verified
Raw History Blame Contribute Delete
1.05 kB
import streamlit as st
from transformers import pipeline
# Load the summarization pipeline
text_summary = pipeline("summarization", model="sshleifer/distilbart-cnn-12-6")
def summarize_text(input_text):
output = text_summary(input_text)
return output[0]['summary_text']
def run():
st.title("πŸ“„ Text Summary Tool")
st.write("This tool helps you summarize long pieces of text efficiently using AI-powered NLP models.")
st.write("Enter a large text below to generate a summary.")
text = st.text_area("This tool helps you summarize long pieces of text efficiently using AI-powered NLP models.")
# text = st.text_area("Enter your text here:", "")
if st.button("πŸš€ Summarize", help="Click to generate summary"):
if text:
with st.spinner("Generating summary..."):
summary_result = summarize_text(text)
st.markdown("### πŸ“ Summarized Text:")
st.success(summary_result)
else:
st.warning("⚠️ Please enter some text to summarize.")