File size: 930 Bytes
9f27a52
75855be
42c2597
a1d11c2
 
 
 
 
 
ece6dcf
a1d11c2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import streamlit as st
from transformers import pipeline

# Function to extract text from SRT file
def extract_text_from_srt(srt_text):
    lines = srt_text.strip().split("\n")
    # Extract text content from SRT
    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 upload SRT file
srt_file = st.file_uploader("Upload SRT file", type=["srt"])

if srt_file is not None:
    # Read uploaded SRT file
    srt_text = srt_file.read().decode("utf-8")
    # Extract text from SRT
    text_to_summarize = extract_text_from_srt(srt_text)
    # Summarize text
    summary = summarizer(text_to_summarize, max_length=150, min_length=30, do_sample=False)
    # Display summary
    st.subheader("Summary:")
    st.write(summary[0]["summary_text"])