fffiloni commited on
Commit
0a6b408
·
verified ·
1 Parent(s): fe34ba6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -4
app.py CHANGED
@@ -187,9 +187,9 @@ def process_final_combination(audio_in, chosen_translated, volume, cut_start, vi
187
  temp_output_path = overlay_audio(audio_in, chosen_translated, volume, cut_start)
188
 
189
  if video_input:
190
- return gr.update(value=temp_output_path, visible=True), gr.update(visible=True), gr.update(visible=True), gr.update(visible=True)
191
  else:
192
- return gr.update(value=temp_output_path, visible=True), gr.update(visible=False), gr.update(visible=True), gr.update(visible=True)
193
 
194
  def replace_video_audio(video_path: str, new_audio_path: str) -> str:
195
  """Replaces the original audio in the video and extends it if the new audio is longer.
@@ -237,6 +237,9 @@ def replace_video_audio(video_path: str, new_audio_path: str) -> str:
237
 
238
  def clean_previous_video_input():
239
  return gr.update(value=None)
 
 
 
240
 
241
  def hide_previous():
242
  return gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False)
@@ -264,7 +267,7 @@ with gr.Blocks(css=css) as demo:
264
  visible=False,
265
  scale=2
266
  )
267
- choose_this_btn = gr.Button("Apply this one as translated overlay", scale=1, visible=False)
268
  with gr.Row():
269
  volume_reduction = gr.Slider(label="Volume reduction", minimum=0, maximum=60, step=1, value=30, visible=False)
270
  cut_start = gr.Slider(label="Cut start", minimum=0.0, maximum=4.0, step=0.1, value=2.0, visible=False)
@@ -303,12 +306,20 @@ with gr.Blocks(css=css) as demo:
303
  )
304
 
305
  choose_this_btn.click(
 
 
 
 
306
  fn = process_final_combination,
307
  inputs = [audio_input, dropdown_wav_selector, volume_reduction, cut_start, video_input],
308
- outputs = [combined_output, apply_to_video_btn, volume_reduction, cut_start]
309
  )
310
 
311
  apply_to_video_btn.click(
 
 
 
 
312
  fn = replace_video_audio,
313
  inputs = [video_input, combined_output],
314
  outputs = [final_video_out]
 
187
  temp_output_path = overlay_audio(audio_in, chosen_translated, volume, cut_start)
188
 
189
  if video_input:
190
+ return gr.update(value=temp_output_path, visible=True), gr.update(visible=True)
191
  else:
192
+ return gr.update(value=temp_output_path, visible=True), gr.update(visible=False)
193
 
194
  def replace_video_audio(video_path: str, new_audio_path: str) -> str:
195
  """Replaces the original audio in the video and extends it if the new audio is longer.
 
237
 
238
  def clean_previous_video_input():
239
  return gr.update(value=None)
240
+
241
+ def show_upcoming_component():
242
+ return gr.update(visible=True)
243
 
244
  def hide_previous():
245
  return gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False)
 
267
  visible=False,
268
  scale=2
269
  )
270
+ choose_this_btn = gr.Button("Apply this one as translated audio overlay", scale=1, visible=False)
271
  with gr.Row():
272
  volume_reduction = gr.Slider(label="Volume reduction", minimum=0, maximum=60, step=1, value=30, visible=False)
273
  cut_start = gr.Slider(label="Cut start", minimum=0.0, maximum=4.0, step=0.1, value=2.0, visible=False)
 
306
  )
307
 
308
  choose_this_btn.click(
309
+ fn = show_upcoming_component,
310
+ inputs=None,
311
+ outputs=[combined_output]
312
+ ).then(
313
  fn = process_final_combination,
314
  inputs = [audio_input, dropdown_wav_selector, volume_reduction, cut_start, video_input],
315
+ outputs = [combined_output, apply_to_video_btn]
316
  )
317
 
318
  apply_to_video_btn.click(
319
+ fn = show_upcoming_component,
320
+ inputs=None,
321
+ outputs=[final_video_out]
322
+ ).then(
323
  fn = replace_video_audio,
324
  inputs = [video_input, combined_output],
325
  outputs = [final_video_out]