Spaces:
Sleeping
Sleeping
FrancoisHB
commited on
Commit
•
a8924ed
1
Parent(s):
5f56b80
Commit Test SRT
Browse files
app.py
CHANGED
@@ -1,31 +1,31 @@
|
|
1 |
import streamlit as st
|
2 |
from transformers import pipeline
|
3 |
|
4 |
-
# Function to extract text from SRT
|
5 |
-
|
6 |
-
def extract_text_from_srt(srt_text):
|
7 |
lines = srt_text.strip().split("\n")
|
8 |
-
|
9 |
-
texts = [line.split("\n")[2] for line in lines if len(line.split("\n")) > 2 and not line.startswith("0")]
|
10 |
return " ".join(texts)
|
11 |
|
12 |
-
|
13 |
# Load summarization pipeline
|
14 |
summarizer = pipeline("summarization")
|
15 |
|
16 |
# Streamlit app
|
17 |
st.title("SRT Summarization")
|
18 |
|
19 |
-
# Text area for user to
|
20 |
-
|
21 |
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
|
|
|
|
|
|
|
1 |
import streamlit as st
|
2 |
from transformers import pipeline
|
3 |
|
4 |
+
# Function to extract text from SRT-formatted text
|
5 |
+
def extract_text_from_srt_text(srt_text):
|
|
|
6 |
lines = srt_text.strip().split("\n")
|
7 |
+
texts = [line.split("\n")[2] for line in lines if not line.startswith("0")]
|
|
|
8 |
return " ".join(texts)
|
9 |
|
|
|
10 |
# Load summarization pipeline
|
11 |
summarizer = pipeline("summarization")
|
12 |
|
13 |
# Streamlit app
|
14 |
st.title("SRT Summarization")
|
15 |
|
16 |
+
# Text area for user to input SRT-formatted text
|
17 |
+
srt_text_input = st.text_area("Paste SRT-formatted text here:")
|
18 |
|
19 |
+
# Button to trigger summarization
|
20 |
+
if st.button("Summarize"):
|
21 |
+
# Check if text area is not empty
|
22 |
+
if srt_text_input.strip():
|
23 |
+
# Extract text from SRT-formatted text
|
24 |
+
text_to_summarize = extract_text_from_srt_text(srt_text_input)
|
25 |
+
# Summarize text
|
26 |
+
summary = summarizer(text_to_summarize, max_length=1500, min_length=10, do_sample=False)
|
27 |
+
# Display summary
|
28 |
+
st.subheader("Summary:")
|
29 |
+
st.write(summary[0]["summary_text"])
|
30 |
+
else:
|
31 |
+
st.warning("Please enter some SRT-formatted text.")
|