LAP-DEV commited on
Commit
a6edb4a
·
verified ·
1 Parent(s): 1143f02

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -9
app.py CHANGED
@@ -98,14 +98,15 @@ class App:
98
  with gr.Row():
99
  with gr.Column(scale=1):
100
  with gr.Row():
101
- input_multi = gr.Radio(["Single", "Multiple"], label="Process one or multiple files", value="Single")
102
  with gr.Row():
103
  dd_file_format = gr.Dropdown(choices=["CSV","SRT","TXT"], value="CSV", label="Output format", multiselect=True, interactive=True, visible=True)
104
  with gr.Row():
105
  cb_timestamp_preview = gr.Checkbox(value=whisper_params["add_timestamp_preview"],label="Show preview with timestamps", interactive=True)
106
  cb_timestamp_file = gr.Checkbox(value=whisper_params["add_timestamp_file"], label="Add timestamp to filenames", interactive=True)
107
  with gr.Column(scale=4):
108
- input_file = gr.Video(type='filepath', elem_id="audio_input", show_download_button=True, visible=True, interactive=True)
 
109
  input_file_multi = gr.Files(label="Upload one or more audio/video files here", elem_id="audio_input", type='filepath', file_count="multiple", allow_reordering=True, file_types=["audio","video"], visible=False, interactive=True)
110
 
111
  with gr.Row():
@@ -267,7 +268,8 @@ class App:
267
  uvr_save_file=cb_uvr_save_file, uvr_enable_offload=cb_uvr_enable_offload
268
  ),
269
  input_multi,
270
- input_file,
 
271
  input_file_multi,
272
  dd_file_format,
273
  cb_timestamp_file,
@@ -316,7 +318,7 @@ class App:
316
  visible=self.args.colab,
317
  value="")
318
 
319
- whisper_params, input_multi, input_file, input_file_multi, dd_file_format, cb_timestamp_file, cb_translate_output, dd_translate_model, dd_target_lang, cb_timestamp_preview = self.create_whisper_parameters()
320
 
321
  with gr.Row():
322
  btn_run = gr.Button("Transcribe", variant="primary")
@@ -330,14 +332,14 @@ class App:
330
  files_subtitles = gr.Files(label="Output data", interactive=False, file_count="multiple")
331
  # btn_openfolder = gr.Button('📂', scale=1)
332
 
333
- params = [input_file, input_file_multi, input_multi, tb_input_folder, dd_file_format, cb_timestamp_file, cb_translate_output, dd_translate_model, dd_target_lang, cb_timestamp_preview]
334
 
335
  btn_run.click(fn=self.whisper_inf.transcribe_file,
336
  inputs=params + whisper_params.as_list(),
337
  outputs=[tb_indicator, files_subtitles, tb_info])
338
  # btn_openfolder.click(fn=lambda: self.open_folder("outputs"), inputs=None, outputs=None)
339
 
340
- input_multi.change(fn=self.update_visibility,inputs=input_multi,outputs=[input_file,input_file_multi])
341
 
342
  with gr.TabItem("Device info"): # tab2
343
  with gr.Column():
@@ -376,10 +378,12 @@ class App:
376
 
377
  @staticmethod
378
  def update_visibility(radio_text):
379
- if radio_text == "Single":
380
- return gr.update(visible=True), gr.update(visible=False)
 
 
381
  else:
382
- return gr.update(visible=False), gr.update(visible=True)
383
 
384
  # Create the parser for command-line arguments
385
  parser = argparse.ArgumentParser()
 
98
  with gr.Row():
99
  with gr.Column(scale=1):
100
  with gr.Row():
101
+ input_multi = gr.Radio(["Audio", "Video", "Multiple"], label="Process one or multiple files", value="Audio")
102
  with gr.Row():
103
  dd_file_format = gr.Dropdown(choices=["CSV","SRT","TXT"], value="CSV", label="Output format", multiselect=True, interactive=True, visible=True)
104
  with gr.Row():
105
  cb_timestamp_preview = gr.Checkbox(value=whisper_params["add_timestamp_preview"],label="Show preview with timestamps", interactive=True)
106
  cb_timestamp_file = gr.Checkbox(value=whisper_params["add_timestamp_file"], label="Add timestamp to filenames", interactive=True)
107
  with gr.Column(scale=4):
108
+ input_file_audio = gr.Audio(type='filepath', elem_id="audio_input", show_download_button=True, visible=True, interactive=True)
109
+ input_file_video = gr.Video(elem_id="audio_input", show_download_button=True, visible=False, interactive=True)
110
  input_file_multi = gr.Files(label="Upload one or more audio/video files here", elem_id="audio_input", type='filepath', file_count="multiple", allow_reordering=True, file_types=["audio","video"], visible=False, interactive=True)
111
 
112
  with gr.Row():
 
268
  uvr_save_file=cb_uvr_save_file, uvr_enable_offload=cb_uvr_enable_offload
269
  ),
270
  input_multi,
271
+ input_file_audio,
272
+ input_file_video,
273
  input_file_multi,
274
  dd_file_format,
275
  cb_timestamp_file,
 
318
  visible=self.args.colab,
319
  value="")
320
 
321
+ whisper_params, input_multi, input_file_audio, input_file_video, input_file_multi, dd_file_format, cb_timestamp_file, cb_translate_output, dd_translate_model, dd_target_lang, cb_timestamp_preview = self.create_whisper_parameters()
322
 
323
  with gr.Row():
324
  btn_run = gr.Button("Transcribe", variant="primary")
 
332
  files_subtitles = gr.Files(label="Output data", interactive=False, file_count="multiple")
333
  # btn_openfolder = gr.Button('📂', scale=1)
334
 
335
+ params = [input_file_audio, input_file_multi, input_multi, tb_input_folder, dd_file_format, cb_timestamp_file, cb_translate_output, dd_translate_model, dd_target_lang, cb_timestamp_preview]
336
 
337
  btn_run.click(fn=self.whisper_inf.transcribe_file,
338
  inputs=params + whisper_params.as_list(),
339
  outputs=[tb_indicator, files_subtitles, tb_info])
340
  # btn_openfolder.click(fn=lambda: self.open_folder("outputs"), inputs=None, outputs=None)
341
 
342
+ input_multi.change(fn=self.update_visibility,inputs=input_multi,outputs=[input_file_audio,input_file_video,input_file_multi])
343
 
344
  with gr.TabItem("Device info"): # tab2
345
  with gr.Column():
 
378
 
379
  @staticmethod
380
  def update_visibility(radio_text):
381
+ if radio_text == "Audio":
382
+ return gr.update(visible=True), gr.update(visible=False), gr.update(visible=False)
383
+ elif radio_text == "video":
384
+ return gr.update(visible=False), gr.update(visible=True), gr.update(visible=False)
385
  else:
386
+ return gr.update(visible=False), gr.update(visible=False), gr.update(visible=True)
387
 
388
  # Create the parser for command-line arguments
389
  parser = argparse.ArgumentParser()