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