Maximofn commited on
Commit
1fbddba
1 Parent(s): d6c6cf5

Rename variables and functions into app.py to make code easyer to read

Browse files
Files changed (1) hide show
  1. app.py +98 -111
app.py CHANGED
@@ -204,7 +204,7 @@ def subtify_no_ui():
204
  print("\n\n")
205
  progress_bar.update(1)
206
 
207
- def remove_all():
208
  command = f"rm -r audios"
209
  os.system(command)
210
  command = f"rm -r chunks"
@@ -223,45 +223,27 @@ def remove_all():
223
  # # def copy_url_from_clipboard():
224
  # # return pyperclip.paste()
225
 
226
- def clear_video_url():
227
  visible = False
228
- num_speaker = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]
229
- image = gr.Image(visible=visible, scale=1)
230
- source_languaje = gr.Dropdown(visible=visible, label="Source languaje", show_label=True, value="English", choices=language_dict, scale=1, interactive=True)
231
- target_languaje = gr.Dropdown(visible=visible, label="Target languaje", show_label=True, value="Español", choices=language_dict, scale=1, interactive=True)
232
- number_of_speakers = gr.Dropdown(visible=visible, label="Number of speakers", show_label=True, value=10, choices=num_speaker, scale=1, interactive=True)
233
- subtify_button = gr.Button(size="lg", value="subtify", min_width="10px", scale=0, visible=visible)
234
- start_block = gr.Textbox(placeholder="Waiting", label="Start block", elem_id="start_block", interactive=False, visible=visible)
235
- video_donwloaded = gr.Textbox(placeholder="Waiting", label="Video downloaded", elem_id="video_downloaded", interactive=False, visible=visible)
236
- video_sliced = gr.Textbox(placeholder="Waiting", label="Video sliced", elem_id="video_sliced", interactive=False, visible=visible)
237
- video_transcribed = gr.Textbox(placeholder="Waiting", label="Video transcribed", elem_id="video_transcribed", interactive=False, visible=visible)
238
- transcriptions_concatenated = gr.Textbox(placeholder="Waiting", label="Transcriptions concatenated", elem_id="transcriptions_concatenated", interactive=False, visible=visible)
239
- video_translated = gr.Textbox(placeholder="Waiting", label="Transcription translated", elem_id="transcription_translated", interactive=False, visible=visible)
240
- video_subtitled = gr.Textbox(placeholder="Waiting", label="Video subtitled", elem_id="video_subtitled", interactive=False, visible=visible)
241
- original_audio_path = gr.Textbox(label="Original audio path", elem_id="original_audio_path", visible=visible)
242
- original_video_path = gr.Textbox(label="Original video path", elem_id="original_video_path", visible=visible)
243
- original_audio_transcribed_path = gr.Textbox(label="Original audio transcribed", elem_id="original_audio_transcribed", visible=visible)
244
- original_audio_translated_path = gr.Textbox(label="Original audio translated", elem_id="original_audio_translated", visible=visible)
245
- subtitled_video = gr.Video(label="Subtitled video", elem_id="subtitled_video", visible=visible, interactive=visible)
246
  return (
247
  "",
248
- image,
249
- source_languaje,
250
- target_languaje,
251
- number_of_speakers,
252
- subtify_button,
253
- start_block,
254
- video_donwloaded,
255
- video_sliced,
256
- video_transcribed,
257
- transcriptions_concatenated,
258
- video_translated,
259
- video_subtitled,
260
- original_audio_path,
261
- original_video_path,
262
- original_audio_transcribed_path,
263
- original_audio_translated_path,
264
- subtitled_video,
265
  )
266
 
267
  def get_youtube_thumbnail(url):
@@ -270,15 +252,25 @@ def get_youtube_thumbnail(url):
270
  return thumbnail_url
271
 
272
  def is_valid_youtube_url(url):
 
 
 
 
273
  patron_youtube = r'(https?://)?(www\.)?(youtube\.com/watch\?v=|youtu\.be/)[\w-]+'
274
- if not re.match(patron_youtube, url):
275
- return False
276
- return True
 
 
 
 
 
 
277
 
278
  def is_valid_url(url):
 
279
  source_languaje = gr.Dropdown(visible=True, label="Source languaje", show_label=True, value="English", choices=language_dict, scale=1, interactive=True)
280
  target_languaje = gr.Dropdown(visible=True, label="Target languaje", show_label=True, value="Español", choices=language_dict, scale=1, interactive=True)
281
- num_speaker = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]
282
  number_of_speakers = gr.Dropdown(visible=True, label="Number of speakers", show_label=True, value=10, choices=num_speaker, scale=1, interactive=True)
283
  subtify_button = gr.Button(size="lg", value="subtify", min_width="10px", scale=0, visible=True)
284
 
@@ -305,13 +297,14 @@ def is_valid_url(url):
305
 
306
  # Twitch
307
  elif "twitch" in url.lower() or "twitch.tv" in url.lower():
308
- return (
309
- gr.Image(value="assets/twitch.webp", visible=True, show_download_button=False, container=False),
310
- source_languaje,
311
- target_languaje,
312
- number_of_speakers,
313
- subtify_button,
314
- )
 
315
 
316
  # Error
317
  visible = False
@@ -328,38 +321,31 @@ def is_valid_url(url):
328
  subtify_button,
329
  )
330
 
331
- def change_visibility_texboxes(url):
332
- start_block = gr.Textbox(value="Done", label="Start block", elem_id="start_block", interactive=False, visible=False)
333
- video_donwloaded = gr.Textbox(placeholder="Waiting", label="Video downloaded", elem_id="video_downloaded", interactive=False, visible=True)
334
- video_sliced = gr.Textbox(placeholder="Waiting", label="Video sliced", elem_id="video_sliced", interactive=False, visible=True)
335
- video_transcribed = gr.Textbox(placeholder="Waiting", label="Video transcribed", elem_id="video_transcribed", interactive=False, visible=True)
336
- transcriptions_concatenated = gr.Textbox(placeholder="Waiting", label="Transcriptions concatenated", elem_id="transcriptions_concatenated", interactive=False, visible=True)
337
- video_translated = gr.Textbox(placeholder="Waiting", label="Transcription translated", elem_id="transcription_translated", interactive=False, visible=True)
338
- video_subtitled = gr.Textbox(placeholder="Waiting", label="Video subtitled", elem_id="video_subtitled", interactive=False, visible=True)
339
 
340
  return (
341
- start_block,
342
- video_donwloaded,
343
- video_sliced,
344
- video_transcribed,
345
- transcriptions_concatenated,
346
- video_translated,
347
- video_subtitled,
348
  )
349
 
350
  def get_audio_and_video_from_video(url):
351
  python_file = "download.py"
352
  command = f"python {python_file} {url}"
353
  os.system(command)
354
- sleep(5)
355
 
356
  audio = "audios/download_audio.mp3"
357
  video = "videos/download_video.mp4"
358
 
359
  return (
360
- gr.Textbox(value="Ok", label="Video downloaded", elem_id="video_downloaded", interactive=False, visible=True),
361
- gr.Textbox(value=audio, label="Original audio path", elem_id="original_audio_path", visible=False),
362
- gr.Textbox(value=video, label="Original video path", elem_id="original_video_path", visible=False),
363
  )
364
 
365
  def slice_audio(audio_path):
@@ -369,6 +355,7 @@ def slice_audio(audio_path):
369
  os.makedirs(folder_vocals)
370
  if not os.path.exists(folder_chunck):
371
  os.makedirs(folder_chunck)
 
372
  python_file = "slice_audio.py"
373
  command = f"python {python_file} {audio_path} {SECONDS}"
374
  os.system(command)
@@ -377,10 +364,9 @@ def slice_audio(audio_path):
377
  f.write(str(0))
378
  command = f"mv {folder_chunck}/*.mp3 {folder_vocals}/"
379
  os.system(command)
380
- # sleep(5)
381
 
382
  return (
383
- gr.Textbox(value="Ok", label="Video sliced", elem_id="video_sliced", interactive=False, visible=True)
384
  )
385
 
386
  def trascribe_audio(source_languaje):
@@ -390,6 +376,7 @@ def trascribe_audio(source_languaje):
390
  speakers_file = "vocals/speakers.txt"
391
  command = f"python {python_file} {chunck_file} {source_languaje} {speakers_file} {DEVICE} {not SEPARE_VOCALS}"
392
  os.system(command)
 
393
  with open(chunck_file, 'r') as f:
394
  files = f.read().splitlines()
395
  with open(speakers_file, 'r') as f:
@@ -413,18 +400,20 @@ def trascribe_audio(source_languaje):
413
  os.system(command)
414
 
415
  return (
416
- gr.Textbox(value="Ok", label="Video transcribed", elem_id="video_transcribed", interactive=False, visible=True)
417
  )
418
 
419
  def concatenate_transcriptions():
420
  folder_concatenated = "concatenated_transcriptions"
421
  if not os.path.exists(folder_concatenated):
422
  os.makedirs(folder_concatenated)
 
423
  chunck_file = "chunks/output_files.txt"
424
  speakers_file = "vocals/speakers.txt"
425
  python_file = "concat_transcriptions.py"
426
  command = f"python {python_file} {chunck_file} {SECONDS} {speakers_file}"
427
  os.system(command)
 
428
  with open(chunck_file, 'r') as f:
429
  files = f.read().splitlines()
430
  for file in files:
@@ -436,32 +425,30 @@ def concatenate_transcriptions():
436
  os.system(command)
437
 
438
  audio_transcribed = "concatenated_transcriptions/download_audio.srt"
439
- with open(audio_transcribed, 'r') as f:
440
- result = f.read()
441
 
442
  return (
443
- gr.Textbox(value="Ok", label="Transcriptions concatenated", elem_id="transcriptions_concatenated", interactive=False, visible=True),
444
- gr.Textbox(value=audio_transcribed, label="Original audio transcribed", elem_id="original_audio_transcribed", visible=False),
445
  )
446
 
447
  def translate_transcription(original_audio_transcribed_path, source_languaje, target_languaje):
448
  folder_translated_transcriptions = "translated_transcriptions"
449
  if not os.path.exists(folder_translated_transcriptions):
450
  os.makedirs(folder_translated_transcriptions)
 
451
  python_file = "translate_transcriptions.py"
452
  command = f"python {python_file} {original_audio_transcribed_path} --source_languaje {source_languaje} --target_languaje {target_languaje} --device {DEVICE}"
453
  os.system(command)
454
 
455
  translated_transcription = f"translated_transcriptions/download_audio_{target_languaje}.srt"
456
- with open(translated_transcription, 'r') as f:
457
- result = f.read()
458
  transcription_file = "concatenated_transcriptions/download_audio.srt"
459
  command = f"rm {transcription_file}"
460
  os.system(command)
461
 
462
  return (
463
- gr.Textbox(value="Ok", label="Transcription translated", elem_id="transcription_translated", interactive=False, visible=True),
464
- gr.Textbox(value=translated_transcription, label="Original audio translated", elem_id="original_audio_translated", visible=False)
465
  )
466
 
467
  def add_translated_subtitles_to_video(original_video_path, original_audio_path, original_audio_translated_path):
@@ -483,8 +470,8 @@ def add_translated_subtitles_to_video(original_video_path, original_audio_path,
483
  subtitled_video = "videos/download_video_with_subtitles.mp4"
484
 
485
  return (
486
- gr.Textbox(value="Ok", label="Video subtitled", elem_id="video_subtitled", interactive=False, visible=True),
487
- gr.Video(value=subtitled_video, label="Subtitled video", elem_id="subtitled_video", visible=True, interactive=False),
488
  )
489
 
490
  def subtify():
@@ -509,14 +496,14 @@ def subtify():
509
  with gr.Row():
510
  subtify_button = gr.Button(size="lg", value="subtify", min_width="10px", scale=0, visible=visible)
511
 
512
- start_block = gr.Textbox(placeholder="Waiting", label="Start block", elem_id="start_block", interactive=False, visible=visible)
513
  with gr.Row():
514
- video_donwloaded = gr.Textbox(placeholder="Waiting", label="Video downloaded", elem_id="video_downloaded", interactive=False, visible=visible)
515
- video_sliced = gr.Textbox(placeholder="Waiting", label="Video sliced", elem_id="video_sliced", interactive=False, visible=visible)
516
- video_transcribed = gr.Textbox(placeholder="Waiting", label="Video transcribed", elem_id="video_transcribed", interactive=False, visible=visible)
517
- transcriptions_concatenated = gr.Textbox(placeholder="Waiting", label="Transcriptions concatenated", elem_id="transcriptions_concatenated", interactive=False, visible=visible)
518
- video_translated = gr.Textbox(placeholder="Waiting", label="Transcription translated", elem_id="transcription_translated", interactive=False, visible=visible)
519
- video_subtitled = gr.Textbox(placeholder="Waiting", label="Video subtitled", elem_id="video_subtitled", interactive=False, visible=visible)
520
 
521
  original_audio_path = gr.Textbox(label="Original audio path", elem_id="original_audio_path", visible=visible)
522
  original_video_path = gr.Textbox(label="Original video path", elem_id="original_video_path", visible=visible)
@@ -527,7 +514,7 @@ def subtify():
527
  # Events
528
  # copy_button.click(fn=copy_url_from_clipboard, outputs=url_textbox)
529
  delete_button.click(
530
- fn=clear_video_url,
531
  outputs=[
532
  url_textbox,
533
  image,
@@ -535,13 +522,13 @@ def subtify():
535
  target_languaje,
536
  number_of_speakers,
537
  subtify_button,
538
- start_block,
539
- video_donwloaded,
540
- video_sliced,
541
- video_transcribed,
542
- transcriptions_concatenated,
543
- video_translated,
544
- video_subtitled,
545
  subtitled_video,
546
  ]
547
  )
@@ -552,36 +539,36 @@ def subtify():
552
  )
553
  subtify_button.click(
554
  fn=change_visibility_texboxes,
555
- outputs=[start_block, video_donwloaded, video_sliced, video_transcribed, transcriptions_concatenated, video_translated, video_subtitled]
556
  )
557
- start_block.change(
558
  fn=get_audio_and_video_from_video,
559
  inputs=[url_textbox],
560
- outputs=[video_donwloaded, original_audio_path, original_video_path]
561
  )
562
- video_donwloaded.change(
563
  fn=slice_audio,
564
  inputs=[original_audio_path],
565
- outputs=[video_sliced]
566
  )
567
- video_sliced.change(
568
  fn=trascribe_audio,
569
  inputs=[source_languaje],
570
- outputs=[video_transcribed]
571
  )
572
- video_transcribed.change(
573
  fn=concatenate_transcriptions,
574
- outputs=[transcriptions_concatenated, original_audio_transcribed_path]
575
  )
576
- transcriptions_concatenated.change(
577
  fn=translate_transcription,
578
  inputs=[original_audio_transcribed_path, source_languaje, target_languaje],
579
- outputs=[video_translated, original_audio_translated_path]
580
  )
581
- video_translated.change(
582
  fn=add_translated_subtitles_to_video,
583
  inputs=[original_video_path, original_audio_path, original_audio_translated_path],
584
- outputs=[video_subtitled, subtitled_video]
585
  )
586
 
587
  demo.launch()
@@ -590,12 +577,12 @@ def subtify():
590
  if __name__ == "__main__":
591
  parser = argparse.ArgumentParser()
592
  parser.add_argument("--no_ui", action="store_true")
593
- parser.add_argument("--remove_all", action="store_true")
594
  args = parser.parse_args()
595
 
596
  if args.no_ui:
597
  subtify_no_ui()
598
- elif args.remove_all:
599
- remove_all()
600
  else:
601
  subtify()
 
204
  print("\n\n")
205
  progress_bar.update(1)
206
 
207
+ def remove_all_files():
208
  command = f"rm -r audios"
209
  os.system(command)
210
  command = f"rm -r chunks"
 
223
  # # def copy_url_from_clipboard():
224
  # # return pyperclip.paste()
225
 
226
+ def reset_frontend():
227
  visible = False
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
228
  return (
229
  "",
230
+ gr.Image(visible=visible),
231
+ gr.Dropdown(visible=visible),
232
+ gr.Dropdown(visible=visible),
233
+ gr.Dropdown(visible=visible),
234
+ gr.Button(visible=visible),
235
+ gr.Textbox(visible=visible),
236
+ gr.Textbox(visible=visible),
237
+ gr.Textbox(visible=visible),
238
+ gr.Textbox(visible=visible),
239
+ gr.Textbox(visible=visible),
240
+ gr.Textbox(visible=visible),
241
+ gr.Textbox(visible=visible),
242
+ gr.Textbox(visible=visible),
243
+ gr.Textbox(visible=visible),
244
+ gr.Textbox(visible=visible),
245
+ gr.Textbox(visible=visible),
246
+ gr.Video(visible=visible),
247
  )
248
 
249
  def get_youtube_thumbnail(url):
 
252
  return thumbnail_url
253
 
254
  def is_valid_youtube_url(url):
255
+ # This regular expression should match the following YouTube URL formats:
256
+ # - https://youtube.com/watch?v=video_id
257
+ # - https://www.youtube.com/watch?v=video_id
258
+ # - https://youtu.be/video_id
259
  patron_youtube = r'(https?://)?(www\.)?(youtube\.com/watch\?v=|youtu\.be/)[\w-]+'
260
+ return bool(re.match(patron_youtube, url))
261
+
262
+ def is_valid_twitch_url(url):
263
+ # This regular expression should match the following Twitch URL formats:
264
+ # - https://twitch.tv/channel_name
265
+ # - https://www.twitch.tv/channel_name
266
+ # - https://twitch.tv/videos/video_id
267
+ twitch_pattern = r'(https?://)?(www\.)?twitch\.tv/(videos/\d+|\w+)'
268
+ return bool(re.match(twitch_pattern, url))
269
 
270
  def is_valid_url(url):
271
+ num_speaker = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]
272
  source_languaje = gr.Dropdown(visible=True, label="Source languaje", show_label=True, value="English", choices=language_dict, scale=1, interactive=True)
273
  target_languaje = gr.Dropdown(visible=True, label="Target languaje", show_label=True, value="Español", choices=language_dict, scale=1, interactive=True)
 
274
  number_of_speakers = gr.Dropdown(visible=True, label="Number of speakers", show_label=True, value=10, choices=num_speaker, scale=1, interactive=True)
275
  subtify_button = gr.Button(size="lg", value="subtify", min_width="10px", scale=0, visible=True)
276
 
 
297
 
298
  # Twitch
299
  elif "twitch" in url.lower() or "twitch.tv" in url.lower():
300
+ if is_valid_twitch_url(url):
301
+ return (
302
+ gr.Image(value="assets/twitch.webp", visible=True, show_download_button=False, container=False),
303
+ source_languaje,
304
+ target_languaje,
305
+ number_of_speakers,
306
+ subtify_button,
307
+ )
308
 
309
  # Error
310
  visible = False
 
321
  subtify_button,
322
  )
323
 
324
+ def change_visibility_texboxes():
 
 
 
 
 
 
 
325
 
326
  return (
327
+ gr.Textbox(value="Done"),
328
+ gr.Textbox(visible=True),
329
+ gr.Textbox(visible=True),
330
+ gr.Textbox(visible=True),
331
+ gr.Textbox(visible=True),
332
+ gr.Textbox(visible=True),
333
+ gr.Textbox(visible=True),
334
  )
335
 
336
  def get_audio_and_video_from_video(url):
337
  python_file = "download.py"
338
  command = f"python {python_file} {url}"
339
  os.system(command)
340
+ sleep(1)
341
 
342
  audio = "audios/download_audio.mp3"
343
  video = "videos/download_video.mp4"
344
 
345
  return (
346
+ gr.Textbox(value="Ok"),
347
+ gr.Textbox(value=audio),
348
+ gr.Textbox(value=video),
349
  )
350
 
351
  def slice_audio(audio_path):
 
355
  os.makedirs(folder_vocals)
356
  if not os.path.exists(folder_chunck):
357
  os.makedirs(folder_chunck)
358
+
359
  python_file = "slice_audio.py"
360
  command = f"python {python_file} {audio_path} {SECONDS}"
361
  os.system(command)
 
364
  f.write(str(0))
365
  command = f"mv {folder_chunck}/*.mp3 {folder_vocals}/"
366
  os.system(command)
 
367
 
368
  return (
369
+ gr.Textbox(value="Ok")
370
  )
371
 
372
  def trascribe_audio(source_languaje):
 
376
  speakers_file = "vocals/speakers.txt"
377
  command = f"python {python_file} {chunck_file} {source_languaje} {speakers_file} {DEVICE} {not SEPARE_VOCALS}"
378
  os.system(command)
379
+
380
  with open(chunck_file, 'r') as f:
381
  files = f.read().splitlines()
382
  with open(speakers_file, 'r') as f:
 
400
  os.system(command)
401
 
402
  return (
403
+ gr.Textbox(value="Ok")
404
  )
405
 
406
  def concatenate_transcriptions():
407
  folder_concatenated = "concatenated_transcriptions"
408
  if not os.path.exists(folder_concatenated):
409
  os.makedirs(folder_concatenated)
410
+
411
  chunck_file = "chunks/output_files.txt"
412
  speakers_file = "vocals/speakers.txt"
413
  python_file = "concat_transcriptions.py"
414
  command = f"python {python_file} {chunck_file} {SECONDS} {speakers_file}"
415
  os.system(command)
416
+
417
  with open(chunck_file, 'r') as f:
418
  files = f.read().splitlines()
419
  for file in files:
 
425
  os.system(command)
426
 
427
  audio_transcribed = "concatenated_transcriptions/download_audio.srt"
 
 
428
 
429
  return (
430
+ gr.Textbox(value="Ok"),
431
+ gr.Textbox(value=audio_transcribed),
432
  )
433
 
434
  def translate_transcription(original_audio_transcribed_path, source_languaje, target_languaje):
435
  folder_translated_transcriptions = "translated_transcriptions"
436
  if not os.path.exists(folder_translated_transcriptions):
437
  os.makedirs(folder_translated_transcriptions)
438
+
439
  python_file = "translate_transcriptions.py"
440
  command = f"python {python_file} {original_audio_transcribed_path} --source_languaje {source_languaje} --target_languaje {target_languaje} --device {DEVICE}"
441
  os.system(command)
442
 
443
  translated_transcription = f"translated_transcriptions/download_audio_{target_languaje}.srt"
444
+
 
445
  transcription_file = "concatenated_transcriptions/download_audio.srt"
446
  command = f"rm {transcription_file}"
447
  os.system(command)
448
 
449
  return (
450
+ gr.Textbox(value="Ok"),
451
+ gr.Textbox(value=translated_transcription)
452
  )
453
 
454
  def add_translated_subtitles_to_video(original_video_path, original_audio_path, original_audio_translated_path):
 
470
  subtitled_video = "videos/download_video_with_subtitles.mp4"
471
 
472
  return (
473
+ gr.Textbox(value="Ok"),
474
+ gr.Video(value=subtitled_video, visible=True),
475
  )
476
 
477
  def subtify():
 
496
  with gr.Row():
497
  subtify_button = gr.Button(size="lg", value="subtify", min_width="10px", scale=0, visible=visible)
498
 
499
+ auxiliar_block = gr.Textbox(placeholder="Waiting", label="Auxiliar block", elem_id="auxiliar_block", interactive=False, visible=visible)
500
  with gr.Row():
501
+ video_donwloaded_progress_info = gr.Textbox(placeholder="Waiting", label="Video downloaded progress info", elem_id="video_donwloaded_progress_info", interactive=False, visible=visible)
502
+ video_sliced_progress_info = gr.Textbox(placeholder="Waiting", label="Video sliced progress info", elem_id="video_sliced_progress_info", interactive=False, visible=visible)
503
+ video_transcribed_progress_info = gr.Textbox(placeholder="Waiting", label="Video transcribed progress info", elem_id="video_transcribed_progress_info", interactive=False, visible=visible)
504
+ transcriptions_concatenated_progress_info = gr.Textbox(placeholder="Waiting", label="Transcriptions concatenated progress info", elem_id="transcriptions_concatenated_progress_info", interactive=False, visible=visible)
505
+ video_translated_progress_info = gr.Textbox(placeholder="Waiting", label="Transcription translated progress info", elem_id="transcription_translated_progress_info", interactive=False, visible=visible)
506
+ video_subtitled_progress_info = gr.Textbox(placeholder="Waiting", label="Video subtitled progress info", elem_id="video_subtitled_progress_info", interactive=False, visible=visible)
507
 
508
  original_audio_path = gr.Textbox(label="Original audio path", elem_id="original_audio_path", visible=visible)
509
  original_video_path = gr.Textbox(label="Original video path", elem_id="original_video_path", visible=visible)
 
514
  # Events
515
  # copy_button.click(fn=copy_url_from_clipboard, outputs=url_textbox)
516
  delete_button.click(
517
+ fn=reset_frontend,
518
  outputs=[
519
  url_textbox,
520
  image,
 
522
  target_languaje,
523
  number_of_speakers,
524
  subtify_button,
525
+ auxiliar_block,
526
+ video_donwloaded_progress_info,
527
+ video_sliced_progress_info,
528
+ video_transcribed_progress_info,
529
+ transcriptions_concatenated_progress_info,
530
+ video_translated_progress_info,
531
+ video_subtitled_progress_info,
532
  subtitled_video,
533
  ]
534
  )
 
539
  )
540
  subtify_button.click(
541
  fn=change_visibility_texboxes,
542
+ outputs=[auxiliar_block, video_donwloaded_progress_info, video_sliced_progress_info, video_transcribed_progress_info, transcriptions_concatenated_progress_info, video_translated_progress_info, video_subtitled_progress_info]
543
  )
544
+ auxiliar_block.change(
545
  fn=get_audio_and_video_from_video,
546
  inputs=[url_textbox],
547
+ outputs=[video_donwloaded_progress_info, original_audio_path, original_video_path]
548
  )
549
+ video_donwloaded_progress_info.change(
550
  fn=slice_audio,
551
  inputs=[original_audio_path],
552
+ outputs=[video_sliced_progress_info]
553
  )
554
+ video_sliced_progress_info.change(
555
  fn=trascribe_audio,
556
  inputs=[source_languaje],
557
+ outputs=[video_transcribed_progress_info]
558
  )
559
+ video_transcribed_progress_info.change(
560
  fn=concatenate_transcriptions,
561
+ outputs=[transcriptions_concatenated_progress_info, original_audio_transcribed_path]
562
  )
563
+ transcriptions_concatenated_progress_info.change(
564
  fn=translate_transcription,
565
  inputs=[original_audio_transcribed_path, source_languaje, target_languaje],
566
+ outputs=[video_translated_progress_info, original_audio_translated_path]
567
  )
568
+ video_translated_progress_info.change(
569
  fn=add_translated_subtitles_to_video,
570
  inputs=[original_video_path, original_audio_path, original_audio_translated_path],
571
+ outputs=[video_subtitled_progress_info, subtitled_video]
572
  )
573
 
574
  demo.launch()
 
577
  if __name__ == "__main__":
578
  parser = argparse.ArgumentParser()
579
  parser.add_argument("--no_ui", action="store_true")
580
+ parser.add_argument("--remove_all_files", action="store_true")
581
  args = parser.parse_args()
582
 
583
  if args.no_ui:
584
  subtify_no_ui()
585
+ elif args.remove_all_files:
586
+ remove_all_files()
587
  else:
588
  subtify()