import streamlit as st from transformers import pipeline # Function to extract text from SRT-formatted text def extract_text_from_srt_text(srt_text): lines = srt_text.strip().split("\n") texts = [line.split("\n")[2] for line in lines if not line.startswith("0")] return " ".join(texts) # Load summarization pipeline summarizer = pipeline("summarization") # Streamlit app st.title("SRT Summarization") # Text area for user to input SRT-formatted text srt_text_input = st.text_area("Paste SRT-formatted text here:") # Button to trigger summarization if st.button("Summarize"): # Check if text area is not empty if srt_text_input.strip(): # Extract text from SRT-formatted text text_to_summarize = extract_text_from_srt_text(srt_text_input) # Summarize text summary = summarizer(text_to_summarize, max_length=1500, min_length=10, do_sample=False) # Display summary st.subheader("Summary:") st.write(summary[0]["summary_text"]) else: st.warning("Please enter some SRT-formatted text.")