Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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("
|
361 |
|
362 |
with gr.Tabs():
|
363 |
# AUDIO TAB
|
364 |
-
with gr.TabItem("
|
365 |
-
gr.HTML(
|
366 |
|
367 |
with gr.Row():
|
368 |
with gr.Column(scale=2):
|
369 |
-
audio_file_input = gr.Files(label="
|
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="
|
373 |
-
merge_files_checkbox = gr.Checkbox(label="
|
374 |
-
gap_slider = gr.Slider(minimum=0, maximum=5000, step=100, value=500, label=
|
375 |
|
376 |
-
audio_submit_button = gr.Button("
|
377 |
-
audio_output_file = gr.File(label="
|
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("
|
387 |
-
gr.HTML("
|
388 |
|
389 |
with gr.Row():
|
390 |
with gr.Column(scale=2):
|
391 |
-
image_file_input = gr.Files(label="
|
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="
|
395 |
|
396 |
-
image_submit_button = gr.Button("
|
397 |
-
image_output_file = gr.File(label="
|
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("
|
407 |
-
gr.HTML("
|
408 |
|
409 |
with gr.Row():
|
410 |
with gr.Column(scale=2):
|
411 |
-
video_input = gr.File(label="
|
412 |
with gr.Column(scale=1):
|
413 |
conversion_type_radio = gr.Radio(
|
414 |
choices=["Video to Video", "Video to Audio"],
|
415 |
-
label="
|
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="
|
422 |
value=default_video
|
423 |
)
|
424 |
|
425 |
-
video_submit_button = gr.Button("
|
426 |
-
video_output_file = gr.File(label="
|
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,
|