Politrees commited on
Commit
9890b84
·
verified ·
1 Parent(s): 8df6073

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -22
app.py CHANGED
@@ -10,6 +10,10 @@ from pydub import AudioSegment
10
  from moviepy import VideoFileClip
11
  from PIL import Image
12
 
 
 
 
 
13
  # ----------------------- FFmpeg utils -----------------------
14
  def _run_ffmpeg(args):
15
  try:
@@ -357,24 +361,24 @@ VIDEO_FORMATS = available_video_extensions()
357
  IMAGE_FORMATS = available_image_extensions()
358
 
359
  with gr.Blocks(theme=gr.themes.Soft()) as demo:
360
- gr.HTML("<center><h1>Universal Media Converter 🎧🎬</h1></center>")
361
 
362
  with gr.Tabs():
363
  # AUDIO TAB
364
- with gr.TabItem("🎶 Audio Converter"):
365
- gr.HTML("<center>Upload one or more audio files and choose the output format. You can also merge files into a single track (optional).</center>")
366
 
367
  with gr.Row():
368
  with gr.Column(scale=2):
369
- audio_file_input = gr.Files(label="Upload Audio Files", file_types=["audio"], height=160)
370
  with gr.Column(scale=1):
371
  default_audio = "mp3" if "mp3" in AUDIO_FORMATS else (AUDIO_FORMATS[0] if AUDIO_FORMATS else None)
372
- audio_format_choice = gr.Dropdown(choices=AUDIO_FORMATS, label="Output Format", value=default_audio)
373
- merge_files_checkbox = gr.Checkbox(label="Merge all files into one")
374
- gap_slider = gr.Slider(minimum=0, maximum=5000, step=100, value=500, label="Gap between files (ms)")
375
 
376
- audio_submit_button = gr.Button("🚀 Convert", variant="primary")
377
- audio_output_file = gr.File(label="Download Result")
378
 
379
  audio_submit_button.click(
380
  fn=process_audio_files,
@@ -383,18 +387,18 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
383
  )
384
 
385
  # IMAGE TAB
386
- with gr.TabItem("🖼️ Image Converter"):
387
- gr.HTML("<center>Upload one or more images and choose the output format.</center>")
388
 
389
  with gr.Row():
390
  with gr.Column(scale=2):
391
- image_file_input = gr.Files(label="Upload Image Files", file_types=["image"], height=160)
392
  with gr.Column(scale=1):
393
  default_image = "png" if "png" in IMAGE_FORMATS else (IMAGE_FORMATS[0] if IMAGE_FORMATS else None)
394
- image_format_choice = gr.Dropdown(choices=IMAGE_FORMATS, label="Output Image Format", value=default_image)
395
 
396
- image_submit_button = gr.Button("🚀 Convert", variant="primary")
397
- image_output_file = gr.File(label="Download Result")
398
 
399
  image_submit_button.click(
400
  fn=process_image_files,
@@ -403,27 +407,27 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
403
  )
404
 
405
  # VIDEO TAB
406
- with gr.TabItem("🎬 Video Converter"):
407
- gr.HTML("<center>Upload a video, then choose to convert it to another video format or to extract its audio.</center>")
408
 
409
  with gr.Row():
410
  with gr.Column(scale=2):
411
- video_input = gr.File(label="Upload Video File", file_types=["video"], height=160)
412
  with gr.Column(scale=1):
413
  conversion_type_radio = gr.Radio(
414
  choices=["Video to Video", "Video to Audio"],
415
- label="Conversion Type",
416
  value="Video to Video"
417
  )
418
  default_video = "mp4" if "mp4" in VIDEO_FORMATS else (VIDEO_FORMATS[0] if VIDEO_FORMATS else None)
419
  video_format_dropdown = gr.Dropdown(
420
  choices=VIDEO_FORMATS,
421
- label="Output Video/Audio Format",
422
  value=default_video
423
  )
424
 
425
- video_submit_button = gr.Button("🚀 Convert", variant="primary")
426
- video_output_file = gr.File(label="Download Result")
427
 
428
  conversion_type_radio.change(
429
  fn=update_format_choices,
 
10
  from moviepy import VideoFileClip
11
  from PIL import Image
12
 
13
+
14
+ from i18n import en, ru, es, fr, de, pt_BR, it, zh_CN, ja, ko, ar, hi, tr
15
+ i18n = gr.I18n(en, ru, es, fr, de, pt_BR, it, zh_CN, ja, ko, ar, hi, tr)
16
+
17
  # ----------------------- FFmpeg utils -----------------------
18
  def _run_ffmpeg(args):
19
  try:
 
361
  IMAGE_FORMATS = available_image_extensions()
362
 
363
  with gr.Blocks(theme=gr.themes.Soft()) as demo:
364
+ gr.HTML(i18n("title_app"))
365
 
366
  with gr.Tabs():
367
  # AUDIO TAB
368
+ with gr.TabItem(i18n("audio_tab")):
369
+ gr.HTML(i18n("audio_description"))
370
 
371
  with gr.Row():
372
  with gr.Column(scale=2):
373
+ audio_file_input = gr.Files(label=i18n("label_audio_file_input"), file_types=["audio"], height=160)
374
  with gr.Column(scale=1):
375
  default_audio = "mp3" if "mp3" in AUDIO_FORMATS else (AUDIO_FORMATS[0] if AUDIO_FORMATS else None)
376
+ audio_format_choice = gr.Dropdown(choices=AUDIO_FORMATS, label=i18n("label_audio_format_choice"), value=default_audio)
377
+ merge_files_checkbox = gr.Checkbox(label=i18n("label_merge_files_checkbox"))
378
+ gap_slider = gr.Slider(minimum=0, maximum=5000, step=100, value=500, label=i18n("label_gap_slider"))
379
 
380
+ audio_submit_button = gr.Button(i18n("сonvert"), variant="primary")
381
+ audio_output_file = gr.File(label=i18n("download_result"))
382
 
383
  audio_submit_button.click(
384
  fn=process_audio_files,
 
387
  )
388
 
389
  # IMAGE TAB
390
+ with gr.TabItem(i18n("image_tab")):
391
+ gr.HTML(i18n("image_description"))
392
 
393
  with gr.Row():
394
  with gr.Column(scale=2):
395
+ image_file_input = gr.Files(label=i18n("label_image_file_input"), file_types=["image"], height=160)
396
  with gr.Column(scale=1):
397
  default_image = "png" if "png" in IMAGE_FORMATS else (IMAGE_FORMATS[0] if IMAGE_FORMATS else None)
398
+ image_format_choice = gr.Dropdown(choices=IMAGE_FORMATS, label=i18n("label_image_format_choice"), value=default_image)
399
 
400
+ image_submit_button = gr.Button(i18n("сonvert"), variant="primary")
401
+ image_output_file = gr.File(label=i18n("download_result"))
402
 
403
  image_submit_button.click(
404
  fn=process_image_files,
 
407
  )
408
 
409
  # VIDEO TAB
410
+ with gr.TabItem(i18n("video_tab")):
411
+ gr.HTML(i18n("video_description"))
412
 
413
  with gr.Row():
414
  with gr.Column(scale=2):
415
+ video_input = gr.File(label=i18n("label_video_input"), file_types=["video"], height=160)
416
  with gr.Column(scale=1):
417
  conversion_type_radio = gr.Radio(
418
  choices=["Video to Video", "Video to Audio"],
419
+ label=i18n("label_conversion_type_radio"),
420
  value="Video to Video"
421
  )
422
  default_video = "mp4" if "mp4" in VIDEO_FORMATS else (VIDEO_FORMATS[0] if VIDEO_FORMATS else None)
423
  video_format_dropdown = gr.Dropdown(
424
  choices=VIDEO_FORMATS,
425
+ label=i18n("label_video_format_dropdown"),
426
  value=default_video
427
  )
428
 
429
+ video_submit_button = gr.Button(i18n("сonvert"), variant="primary")
430
+ video_output_file = gr.File(label=i18n("download_result"))
431
 
432
  conversion_type_radio.change(
433
  fn=update_format_choices,