storresbusquets commited on
Commit
bcb11fe
·
1 Parent(s): ffdfbe8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -6
app.py CHANGED
@@ -1,7 +1,7 @@
1
  import gradio as gr
2
  import whisper
3
  from pytube import YouTube
4
-
5
 
6
  class GradioInference():
7
  def __init__(self):
@@ -10,6 +10,7 @@ class GradioInference():
10
  self.current_size = "base"
11
  self.loaded_model = whisper.load_model(self.current_size)
12
  self.yt = None
 
13
 
14
  def __call__(self, link, lang, size):
15
  if self.yt is None:
@@ -24,7 +25,10 @@ class GradioInference():
24
  self.current_size = size
25
  results = self.loaded_model.transcribe(path, language=lang)
26
 
27
- return results["text"]
 
 
 
28
 
29
  def populate_metadata(self, link):
30
  self.yt = YouTube(link)
@@ -33,7 +37,7 @@ class GradioInference():
33
 
34
  gio = GradioInference()
35
  title = "Youtube Insights"
36
- description = "The All-in-One Video Analytics Tool"
37
 
38
  block = gr.Blocks()
39
  with block:
@@ -44,7 +48,7 @@ with block:
44
  <h1>Youtube Insights</h1>
45
  </div>
46
  <p style="margin-bottom: 10px; font-size: 94%">
47
- The All-in-One Video Analytics Tool
48
  </p>
49
  </div>
50
  """
@@ -59,9 +63,11 @@ with block:
59
  with gr.Row().style(equal_height=True):
60
  img = gr.Image(label="Thumbnail")
61
  text = gr.Textbox(label="Transcription", placeholder="Transcription Output", lines=10)
 
62
  with gr.Row().style(equal_height=True):
63
- btn = gr.Button("Transcribe")
64
- btn.click(gio, inputs=[link, lang, sz], outputs=[text])
65
  link.change(gio.populate_metadata, inputs=[link], outputs=[img, title])
66
 
67
  block.launch()
 
 
1
  import gradio as gr
2
  import whisper
3
  from pytube import YouTube
4
+ from transformers import pipeline
5
 
6
  class GradioInference():
7
  def __init__(self):
 
10
  self.current_size = "base"
11
  self.loaded_model = whisper.load_model(self.current_size)
12
  self.yt = None
13
+ self.summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
14
 
15
  def __call__(self, link, lang, size):
16
  if self.yt is None:
 
25
  self.current_size = size
26
  results = self.loaded_model.transcribe(path, language=lang)
27
 
28
+ # Perform summarization on the transcription
29
+ transcription_summary = self.summarizer(results["text"], max_length=130, min_length=30, do_sample=False)
30
+
31
+ return results["text"], transcription_summary[0]["summary_text"]
32
 
33
  def populate_metadata(self, link):
34
  self.yt = YouTube(link)
 
37
 
38
  gio = GradioInference()
39
  title = "Youtube Insights"
40
+ description = "Your AI-powered video analytics tool"
41
 
42
  block = gr.Blocks()
43
  with block:
 
48
  <h1>Youtube Insights</h1>
49
  </div>
50
  <p style="margin-bottom: 10px; font-size: 94%">
51
+ Your AI-powered video analytics tool
52
  </p>
53
  </div>
54
  """
 
63
  with gr.Row().style(equal_height=True):
64
  img = gr.Image(label="Thumbnail")
65
  text = gr.Textbox(label="Transcription", placeholder="Transcription Output", lines=10)
66
+ summary = gr.Textbox(label="Summary", placeholder="Summary Output", lines=5) # Added summary output
67
  with gr.Row().style(equal_height=True):
68
+ btn = gr.Button("Get video insights") # Updated button label
69
+ btn.click(gio, inputs=[link, lang, sz], outputs=[text, summary]) # Added summary output
70
  link.change(gio.populate_metadata, inputs=[link], outputs=[img, title])
71
 
72
  block.launch()
73
+