import streamlit as st from transformers import pipeline from heapq import nlargest # Function to extract text from SRT-formatted text def extract_text_from_srt_text(srt_text): lines = srt_text.strip().split("\n\n") # Split by empty lines to separate subtitles texts = [subtitle.split("\n")[2] for subtitle in lines if subtitle.strip()] # Extract text from the third line of each subtitle return " ".join(texts) # Function to generate summary from text def generate_summary(text, summary_length): summarizer = pipeline("summarization") summary = summarizer(text, max_length=summary_length, min_length=30, do_sample=False) summary_text = summary[0]["summary_text"] sentences = text.split(". ") top_sentences = nlargest(4, sentences, key=len) top_subjects = "\n".join(top_sentences) return summary_text, top_subjects # Streamlit app st.title("SRT Summarization") # Logo image URL logo_url = "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQ6uQl0omK_PHXBbyaCHdmh3VjCo_Yvgwavmcs5XRF9Rkjx5FpflxyO4yfux6d2ojKsCOA&usqp=CAU" # Replace with your logo image URL # Center the logo st.markdown( f'