Spaces:
Sleeping
Sleeping
FrancoisHB
commited on
Commit
•
4fa5477
1
Parent(s):
00dc49b
Commit Test SRT
Browse files
app.py
CHANGED
@@ -12,7 +12,11 @@ def extract_text_from_srt_text(srt_text):
|
|
12 |
def generate_summary(text, summary_length):
|
13 |
summarizer = pipeline("summarization")
|
14 |
summary = summarizer(text, max_length=summary_length, min_length=30, do_sample=False)
|
15 |
-
|
|
|
|
|
|
|
|
|
16 |
|
17 |
# Streamlit app
|
18 |
st.title("SRT Summarization")
|
@@ -28,13 +32,9 @@ if st.button("Summarize"):
|
|
28 |
with st.spinner("Summarizing..."):
|
29 |
# Extract text from SRT-formatted text
|
30 |
text_to_summarize = extract_text_from_srt_text(srt_text_input)
|
31 |
-
# Generate summary
|
32 |
-
summary = generate_summary(text_to_summarize, 150) # You can adjust the summary length as needed
|
33 |
-
#
|
34 |
-
sentences = text_to_summarize.split(". ")
|
35 |
-
top_sentences = nlargest(4, sentences, key=len)
|
36 |
-
top_subjects = "\n".join(top_sentences)
|
37 |
-
# Display summary and top 4 subjects
|
38 |
st.subheader("Summary:")
|
39 |
st.write(summary)
|
40 |
st.subheader("Top 4 Subjects:")
|
|
|
12 |
def generate_summary(text, summary_length):
|
13 |
summarizer = pipeline("summarization")
|
14 |
summary = summarizer(text, max_length=summary_length, min_length=30, do_sample=False)
|
15 |
+
summary_text = summary[0]["summary_text"]
|
16 |
+
sentences = text.split(". ")
|
17 |
+
top_sentences = nlargest(4, sentences, key=len)
|
18 |
+
top_subjects = "\n".join(top_sentences)
|
19 |
+
return summary_text, top_subjects
|
20 |
|
21 |
# Streamlit app
|
22 |
st.title("SRT Summarization")
|
|
|
32 |
with st.spinner("Summarizing..."):
|
33 |
# Extract text from SRT-formatted text
|
34 |
text_to_summarize = extract_text_from_srt_text(srt_text_input)
|
35 |
+
# Generate summary and top subjects
|
36 |
+
summary, top_subjects = generate_summary(text_to_summarize, 150) # You can adjust the summary length as needed
|
37 |
+
# Display summary and top subjects
|
|
|
|
|
|
|
|
|
38 |
st.subheader("Summary:")
|
39 |
st.write(summary)
|
40 |
st.subheader("Top 4 Subjects:")
|