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

Commit Test SRT

Browse files
Files changed (1) hide show
  1. app.py +22 -5
app.py CHANGED
@@ -1,10 +1,27 @@
1
- import gradio as gr
2
 
 
 
 
 
3
 
4
- def greet(name):
5
- return "Hello " + name
6
 
 
 
7
 
8
- demo = gr.Interface(fn=greet, inputs="text", outputs="text")
9
 
10
- demo.launch()
 
 
 
 
 
 
 
 
 
 
 
 
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
+
26
+ if __name__ == "__main__":
27
+ main()