FrancoisHB commited on
Commit
624b7b6
1 Parent(s): 75855be

Commit Test SRT

Browse files
Files changed (1) hide show
  1. app.py +4 -16
app.py CHANGED
@@ -1,25 +1,13 @@
1
  from transformers import pipeline
2
 
3
- def summarize_srt(srt_text, max_length=100):
4
- # Extract text from SRT format
5
- lines = srt_text.split('\n\n')
6
- text = ' '.join(line.split('\n')[2] for line in lines if line.strip())
7
-
8
- # Initialize the summarization pipeline
9
  summarizer = pipeline("summarization")
10
-
11
- # Summarize the text
12
- summary = summarizer(text, max_length=max_length)
13
-
14
  return summary[0]['summary_text']
15
 
16
  def main():
17
- # Take SRT content as input
18
- srt_content = input("Enter the SRT content:\n")
19
-
20
- max_length = 100 # Maximum length of the summary
21
-
22
- summary = summarize_srt(srt_content, max_length)
23
  print("Summary:")
24
  print(summary)
25
 
 
1
  from transformers import pipeline
2
 
3
+ def summarize_text(input_text, max_length=100):
 
 
 
 
 
4
  summarizer = pipeline("summarization")
5
+ summary = summarizer(input_text, max_length=max_length)
 
 
 
6
  return summary[0]['summary_text']
7
 
8
  def main():
9
+ input_text = input("Enter the text to summarize: ")
10
+ summary = summarize_text(input_text)
 
 
 
 
11
  print("Summary:")
12
  print(summary)
13