LucFast commited on
Commit
2c94bc3
·
1 Parent(s): a2d7dcb

include translation and fix wrong number of input params

Browse files
Files changed (1) hide show
  1. app.py +9 -6
app.py CHANGED
@@ -12,7 +12,7 @@ class GradioInference():
12
  self.loaded_model = whisper.load_model(self.current_size)
13
  self.yt = None
14
 
15
- def download_videos(link):
16
  """Specify the yt-dlp parameters
17
 
18
  Args:
@@ -69,13 +69,14 @@ class GradioInference():
69
  transcribe_options = dict(task="transcribe", **options)
70
  translate_options = dict(task="translate", **options)
71
  results = self.loaded_model.transcribe(path, **transcribe_options)
 
72
 
73
  if subs == "None":
74
- return results["text"]
75
  elif subs == ".srt":
76
- return self.srt(results["segments"])
77
  elif ".csv" == ".csv":
78
- return self.csv(results["segments"])
79
 
80
  def srt(self, segments):
81
  output = ""
@@ -131,9 +132,11 @@ with block:
131
  title = gr.Label(label="Video Title")
132
  with gr.Row().style(equal_height=True):
133
  img = gr.Image(label="Thumbnail")
134
- text = gr.Textbox(label="Transcription", placeholder="Transcription Output", lines=10)
 
 
135
  with gr.Row().style(equal_height=True):
136
  btn = gr.Button("Transcribe")
137
- btn.click(gio, inputs=[link, lang, sz, wt], outputs=[text])
138
  link.change(gio.populate_metadata, inputs=[link], outputs=[img, title])
139
  block.launch()
 
12
  self.loaded_model = whisper.load_model(self.current_size)
13
  self.yt = None
14
 
15
+ def download_videos(self, link):
16
  """Specify the yt-dlp parameters
17
 
18
  Args:
 
69
  transcribe_options = dict(task="transcribe", **options)
70
  translate_options = dict(task="translate", **options)
71
  results = self.loaded_model.transcribe(path, **transcribe_options)
72
+ translation_txt = self.loaded_model.transcribe(path, **translate_options)["text"]
73
 
74
  if subs == "None":
75
+ return results["text"], translation_txt
76
  elif subs == ".srt":
77
+ return self.srt(results["segments"]), translation_txt
78
  elif ".csv" == ".csv":
79
+ return self.csv(results["segments"]), translation_txt
80
 
81
  def srt(self, segments):
82
  output = ""
 
132
  title = gr.Label(label="Video Title")
133
  with gr.Row().style(equal_height=True):
134
  img = gr.Image(label="Thumbnail")
135
+ with gr.Row().style(equal_height=True):
136
+ transcript = gr.Textbox(label="Transcription", placeholder="Transcription Output", lines=10)
137
+ translate = gr.Textbox(label="Translation", placeholder="Translation Output", lines=10)
138
  with gr.Row().style(equal_height=True):
139
  btn = gr.Button("Transcribe")
140
+ btn.click(gio, inputs=[link, lang, sz, wt], outputs=[transcript, translate])
141
  link.change(gio.populate_metadata, inputs=[link], outputs=[img, title])
142
  block.launch()