Add to forntend social media icons, h1 and subtify logo
Browse files- .gitignore +3 -1
- app.py +58 -5
- assets/MFN.min.svg +1 -0
- assets/MFN.svg +12 -0
- assets/facebook.svg +1 -0
- assets/github.svg +1 -0
- assets/instagram.svg +1 -0
- assets/kaggle.svg +1 -0
- assets/linkedin.svg +1 -0
- assets/sitemap.svg +1 -0
- assets/tiktok.svg +1 -0
- assets/twitch.svg +1 -0
- assets/x.svg +1 -0
- assets/youtube.svg +1 -0
.gitignore
CHANGED
@@ -12,4 +12,6 @@ forma_de_onda.ipynb
|
|
12 |
pretrained_models
|
13 |
sepformer.ipynb
|
14 |
modelscope.ipynb
|
15 |
-
audio_cache
|
|
|
|
|
|
12 |
pretrained_models
|
13 |
sepformer.ipynb
|
14 |
modelscope.ipynb
|
15 |
+
audio_cache
|
16 |
+
*.png
|
17 |
+
*.webp
|
app.py
CHANGED
@@ -8,6 +8,7 @@ from lang_list import union_language_dict
|
|
8 |
# import pyperclip
|
9 |
from pytube import YouTube
|
10 |
import re
|
|
|
11 |
|
12 |
NUMBER = 100
|
13 |
DEVICE = "cuda" if torch.cuda.is_available() else "cpu"
|
@@ -29,6 +30,41 @@ YOUTUBE = "youtube"
|
|
29 |
TWITCH = "twitch"
|
30 |
ERROR = "error"
|
31 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
language_dict = union_language_dict()
|
33 |
|
34 |
def subtify_no_ui():
|
@@ -246,6 +282,10 @@ def reset_frontend():
|
|
246 |
gr.Video(visible=visible),
|
247 |
)
|
248 |
|
|
|
|
|
|
|
|
|
249 |
def get_youtube_thumbnail(url):
|
250 |
yt = YouTube(url)
|
251 |
thumbnail_url = yt.thumbnail_url
|
@@ -331,6 +371,7 @@ def change_visibility_texboxes():
|
|
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):
|
@@ -477,15 +518,23 @@ def add_translated_subtitles_to_video(original_video_path, original_audio_path,
|
|
477 |
def subtify():
|
478 |
with gr.Blocks() as demo:
|
479 |
num_speaker = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]
|
|
|
|
|
|
|
|
|
|
|
480 |
|
481 |
# Layout
|
482 |
-
gr.Markdown(
|
|
|
|
|
483 |
with gr.Row(variant="panel"):
|
484 |
url_textbox = gr.Textbox(placeholder="Add video URL here", label="Video URL", elem_id="video_url", scale=1, interactive=True)
|
485 |
# copy_button = gr.Button(size="sm", icon="icons/copy.svg", value="", min_width="10px", scale=0)
|
486 |
delete_button = gr.Button(size="sm", icon="icons/delete.svg", value="", min_width="10px", scale=0)
|
487 |
|
488 |
visible = False
|
|
|
489 |
with gr.Row(equal_height=False):
|
490 |
image = gr.Image(visible=visible, scale=1)
|
491 |
with gr.Column():
|
@@ -496,7 +545,7 @@ def subtify():
|
|
496 |
with gr.Row():
|
497 |
subtify_button = gr.Button(size="lg", value="subtify", min_width="10px", scale=0, visible=visible)
|
498 |
|
499 |
-
|
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)
|
@@ -522,7 +571,7 @@ def subtify():
|
|
522 |
target_languaje,
|
523 |
number_of_speakers,
|
524 |
subtify_button,
|
525 |
-
|
526 |
video_donwloaded_progress_info,
|
527 |
video_sliced_progress_info,
|
528 |
video_transcribed_progress_info,
|
@@ -533,15 +582,19 @@ def subtify():
|
|
533 |
]
|
534 |
)
|
535 |
url_textbox.change(
|
|
|
|
|
|
|
|
|
536 |
fn=is_valid_url,
|
537 |
inputs=url_textbox,
|
538 |
outputs=[image, source_languaje, target_languaje, number_of_speakers, subtify_button]
|
539 |
)
|
540 |
subtify_button.click(
|
541 |
fn=change_visibility_texboxes,
|
542 |
-
outputs=[
|
543 |
)
|
544 |
-
|
545 |
fn=get_audio_and_video_from_video,
|
546 |
inputs=[url_textbox],
|
547 |
outputs=[video_donwloaded_progress_info, original_audio_path, original_video_path]
|
|
|
8 |
# import pyperclip
|
9 |
from pytube import YouTube
|
10 |
import re
|
11 |
+
from PIL import Image
|
12 |
|
13 |
NUMBER = 100
|
14 |
DEVICE = "cuda" if torch.cuda.is_available() else "cpu"
|
|
|
30 |
TWITCH = "twitch"
|
31 |
ERROR = "error"
|
32 |
|
33 |
+
html_social_media = '''
|
34 |
+
<div style="float: right;">
|
35 |
+
<a href="https://maximofn.com/" rel="noopener noreferrer" aria-disabled="false" class="sm secondary svelte-cmf5ev" id="component-1" style="flex-grow: 100;" target="_blank">
|
36 |
+
<img src="http://127.0.0.1:7860/file=assets/MFN.svg" alt="MFN icon" width="16px">
|
37 |
+
</a>
|
38 |
+
<a href="http://github.com/maximofn" rel="noopener noreferrer" aria-disabled="false" class="sm secondary svelte-cmf5ev" id="component-1" style="flex-grow: 100;" target="_blank">
|
39 |
+
<img src="http://127.0.0.1:7860/file=assets/github.svg" alt="github icon">
|
40 |
+
</a>
|
41 |
+
<a href="http://linkedin.com/in/MaximoFN/" rel="noopener noreferrer" aria-disabled="false" class="sm secondary svelte-cmf5ev" id="component-1" style="flex-grow: 100;" target="_blank">
|
42 |
+
<img src="http://127.0.0.1:7860/file=assets/linkedin.svg" alt="linkedin icon">
|
43 |
+
</a>
|
44 |
+
<a href="https://www.facebook.com/profile.php?id=100085177670661" rel="noopener noreferrer" aria-disabled="false" class="sm secondary svelte-cmf5ev" id="component-1" style="flex-grow: 100;" target="_blank">
|
45 |
+
<img src="http://127.0.0.1:7860/file=assets/facebook.svg" alt="facebook icon">
|
46 |
+
</a>
|
47 |
+
<a href="https://twitter.com/Maximo_fn" rel="noopener noreferrer" aria-disabled="false" class="sm secondary svelte-cmf5ev" id="component-1" style="flex-grow: 100;" target="_blank">
|
48 |
+
<img src="http://127.0.0.1:7860/file=assets/x.svg" alt="x icon">
|
49 |
+
</a>
|
50 |
+
<a href="https://www.instagram.com/maximo__fn/" rel="noopener noreferrer" aria-disabled="false" class="sm secondary svelte-cmf5ev" id="component-1" style="flex-grow: 100;" target="_blank">
|
51 |
+
<img src="http://127.0.0.1:7860/file=assets/instagram.svg" alt="instagram icon">
|
52 |
+
</a>
|
53 |
+
<a href="https://www.tiktok.com/@maximo__fn" rel="noopener noreferrer" aria-disabled="false" class="sm secondary svelte-cmf5ev" id="component-1" style="flex-grow: 100;" target="_blank">
|
54 |
+
<img src="http://127.0.0.1:7860/file=assets/tiktok.svg" alt="tiktok icon">
|
55 |
+
</a>
|
56 |
+
<a href="https://www.twitch.tv/maximofn/" rel="noopener noreferrer" aria-disabled="false" class="sm secondary svelte-cmf5ev" id="component-1" style="flex-grow: 100;" target="_blank">
|
57 |
+
<img src="http://127.0.0.1:7860/file=assets/twitch.svg" alt="twitch icon">
|
58 |
+
</a>
|
59 |
+
<a href="https://www.youtube.com/channel/UCdQwg2JU_fWRsHn3yIlf3tw" rel="noopener noreferrer" aria-disabled="false" class="sm secondary svelte-cmf5ev" id="component-1" style="flex-grow: 100;" target="_blank">
|
60 |
+
<img src="http://127.0.0.1:7860/file=assets/youtube.svg" alt="youtube icon">
|
61 |
+
</a>
|
62 |
+
<a href="http://kaggle.com/maximofn" rel="noopener noreferrer" aria-disabled="false" class="sm secondary svelte-cmf5ev" id="component-1" style="flex-grow: 100;" target="_blank">
|
63 |
+
<img src="http://127.0.0.1:7860/file=assets/kaggle.svg" alt="kaggle icon">
|
64 |
+
</a>
|
65 |
+
</div>
|
66 |
+
'''
|
67 |
+
|
68 |
language_dict = union_language_dict()
|
69 |
|
70 |
def subtify_no_ui():
|
|
|
282 |
gr.Video(visible=visible),
|
283 |
)
|
284 |
|
285 |
+
def show_auxiliar_block1():
|
286 |
+
print("show_auxiliar_block1")
|
287 |
+
return gr.Textbox(value="URL checked", visible=True)
|
288 |
+
|
289 |
def get_youtube_thumbnail(url):
|
290 |
yt = YouTube(url)
|
291 |
thumbnail_url = yt.thumbnail_url
|
|
|
371 |
gr.Textbox(visible=True),
|
372 |
gr.Textbox(visible=True),
|
373 |
gr.Textbox(visible=True),
|
374 |
+
gr.Textbox(visible=False),
|
375 |
)
|
376 |
|
377 |
def get_audio_and_video_from_video(url):
|
|
|
518 |
def subtify():
|
519 |
with gr.Blocks() as demo:
|
520 |
num_speaker = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]
|
521 |
+
subtify_logo = Image.open("assets/subtify_logo.webp")
|
522 |
+
subtify_logo_width, subtify_logo_height = subtify_logo.size
|
523 |
+
factor = 5
|
524 |
+
new_width = subtify_logo_width // factor
|
525 |
+
new_height = subtify_logo_height // factor
|
526 |
|
527 |
# Layout
|
528 |
+
gr.Markdown(html_social_media)
|
529 |
+
gr.Markdown("<h1 style='text-align: center;'>Subtify</h1>")
|
530 |
+
gr.Markdown(f"<img src='https://maximofn.com/wp-content/uploads/2023/11/subtify_logo-scaled.webp' style='width: {new_width}px; height: {new_height}px; margin-left: auto; margin-right: auto; display: block;'/>")
|
531 |
with gr.Row(variant="panel"):
|
532 |
url_textbox = gr.Textbox(placeholder="Add video URL here", label="Video URL", elem_id="video_url", scale=1, interactive=True)
|
533 |
# copy_button = gr.Button(size="sm", icon="icons/copy.svg", value="", min_width="10px", scale=0)
|
534 |
delete_button = gr.Button(size="sm", icon="icons/delete.svg", value="", min_width="10px", scale=0)
|
535 |
|
536 |
visible = False
|
537 |
+
auxiliar_block1 = gr.Textbox(label="Auxiliar block 1", elem_id="auxiliar_block1", interactive=False, visible=visible)
|
538 |
with gr.Row(equal_height=False):
|
539 |
image = gr.Image(visible=visible, scale=1)
|
540 |
with gr.Column():
|
|
|
545 |
with gr.Row():
|
546 |
subtify_button = gr.Button(size="lg", value="subtify", min_width="10px", scale=0, visible=visible)
|
547 |
|
548 |
+
auxiliar_block2 = gr.Textbox(placeholder="Waiting", label="Auxiliar block 2", elem_id="auxiliar_block2", interactive=False, visible=visible)
|
549 |
with gr.Row():
|
550 |
video_donwloaded_progress_info = gr.Textbox(placeholder="Waiting", label="Video downloaded progress info", elem_id="video_donwloaded_progress_info", interactive=False, visible=visible)
|
551 |
video_sliced_progress_info = gr.Textbox(placeholder="Waiting", label="Video sliced progress info", elem_id="video_sliced_progress_info", interactive=False, visible=visible)
|
|
|
571 |
target_languaje,
|
572 |
number_of_speakers,
|
573 |
subtify_button,
|
574 |
+
auxiliar_block2,
|
575 |
video_donwloaded_progress_info,
|
576 |
video_sliced_progress_info,
|
577 |
video_transcribed_progress_info,
|
|
|
582 |
]
|
583 |
)
|
584 |
url_textbox.change(
|
585 |
+
fn=show_auxiliar_block1,
|
586 |
+
outputs=[auxiliar_block1]
|
587 |
+
)
|
588 |
+
auxiliar_block1.change(
|
589 |
fn=is_valid_url,
|
590 |
inputs=url_textbox,
|
591 |
outputs=[image, source_languaje, target_languaje, number_of_speakers, subtify_button]
|
592 |
)
|
593 |
subtify_button.click(
|
594 |
fn=change_visibility_texboxes,
|
595 |
+
outputs=[auxiliar_block2, video_donwloaded_progress_info, video_sliced_progress_info, video_transcribed_progress_info, transcriptions_concatenated_progress_info, video_translated_progress_info, video_subtitled_progress_info, auxiliar_block1]
|
596 |
)
|
597 |
+
auxiliar_block2.change(
|
598 |
fn=get_audio_and_video_from_video,
|
599 |
inputs=[url_textbox],
|
600 |
outputs=[video_donwloaded_progress_info, original_audio_path, original_video_path]
|
assets/MFN.min.svg
ADDED
assets/MFN.svg
ADDED
assets/facebook.svg
ADDED
assets/github.svg
ADDED
assets/instagram.svg
ADDED
assets/kaggle.svg
ADDED
assets/linkedin.svg
ADDED
assets/sitemap.svg
ADDED
assets/tiktok.svg
ADDED
assets/twitch.svg
ADDED
assets/x.svg
ADDED
assets/youtube.svg
ADDED