FrancoisHB commited on
Commit
a1d11c2
1 Parent(s): feeaced

Commit Test SRT

Browse files
Files changed (1) hide show
  1. app.py +25 -6
app.py CHANGED
@@ -1,10 +1,29 @@
1
  import streamlit as st
2
  from transformers import pipeline
3
 
4
- pipe = pipeline('summarization')
5
- # pipe = pipeline('sentiment-analysis')
6
- text = st.text_area('enter some text:')
 
 
 
7
 
8
- if text:
9
- out = pipe(text)
10
- st.json(out)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import streamlit as st
2
  from transformers import pipeline
3
 
4
+ # Function to extract text from SRT file
5
+ def extract_text_from_srt(srt_text):
6
+ lines = srt_text.strip().split("\n")
7
+ # Extract text content from SRT
8
+ texts = [line.split("\n")[2] for line in lines if not line.startswith("0")]
9
+ return " ".join(texts)
10
 
11
+ # Load summarization pipeline
12
+ summarizer = pipeline("summarization")
13
+
14
+ # Streamlit app
15
+ st.title("SRT Summarization")
16
+
17
+ # Text area for user to upload SRT file
18
+ srt_file = st.file_uploader("Upload SRT file", type=["srt"])
19
+
20
+ if srt_file is not None:
21
+ # Read uploaded SRT file
22
+ srt_text = srt_file.read().decode("utf-8")
23
+ # Extract text from SRT
24
+ text_to_summarize = extract_text_from_srt(srt_text)
25
+ # Summarize text
26
+ summary = summarizer(text_to_summarize, max_length=150, min_length=30, do_sample=False)
27
+ # Display summary
28
+ st.subheader("Summary:")
29
+ st.write(summary[0]["summary_text"])