Maximofn commited on
Commit
685e082
1 Parent(s): f0ef122

Download subtify logo from web

Browse files
Files changed (1) hide show
  1. app.py +21 -7
app.py CHANGED
@@ -9,6 +9,7 @@ from lang_list import union_language_dict
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,6 +31,13 @@ YOUTUBE = "youtube"
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">
@@ -65,6 +73,16 @@ html_social_media = '''
65
  </div>
66
  '''
67
 
 
 
 
 
 
 
 
 
 
 
68
  language_dict = union_language_dict()
69
 
70
  def subtify_no_ui():
@@ -283,7 +301,6 @@ def reset_frontend():
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):
@@ -518,16 +535,11 @@ def add_translated_subtitles_to_video(original_video_path, original_audio_path,
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)
@@ -624,6 +636,8 @@ def subtify():
624
  outputs=[video_subtitled_progress_info, subtitled_video]
625
  )
626
 
 
 
627
  demo.launch()
628
 
629
 
 
9
  from pytube import YouTube
10
  import re
11
  from PIL import Image
12
+ import urllib.request
13
 
14
  NUMBER = 100
15
  DEVICE = "cuda" if torch.cuda.is_available() else "cpu"
 
31
  TWITCH = "twitch"
32
  ERROR = "error"
33
 
34
+ urllib.request.urlretrieve('https://maximofn.com/wp-content/uploads/2023/11/subtify_logo-scaled.webp', "subtify_logo.webp")
35
+ subtify_logo = Image.open("subtify_logo.webp")
36
+ subtify_logo_width, subtify_logo_height = subtify_logo.size
37
+ factor = 5
38
+ new_width = subtify_logo_width // factor
39
+ new_height = subtify_logo_height // factor
40
+
41
  html_social_media = '''
42
  <div style="float: right;">
43
  <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">
 
73
  </div>
74
  '''
75
 
76
+ html_subtify_logo = f"<img src='http://127.0.0.1:7860/file=subtify_logo.webp' style='width: {new_width}px; height: {new_height}px; margin-left: auto; margin-right: auto; display: block;'/>"
77
+
78
+ html_buy_me_a_coffe = '''
79
+ <div style="float: right;">
80
+ <a href="https://www.buymeacoffee.com/maximofn" target="_blank">
81
+ <img src="https://img.shields.io/badge/Buy_Me_A_Coffee-support_my_work-FFDD00?style=for-the-badge&logo=buy-me-a-coffee&logoColor=white&labelColor=101010" alt="buy me a coffe">
82
+ </a>
83
+ </div>
84
+ '''
85
+
86
  language_dict = union_language_dict()
87
 
88
  def subtify_no_ui():
 
301
  )
302
 
303
  def show_auxiliar_block1():
 
304
  return gr.Textbox(value="URL checked", visible=True)
305
 
306
  def get_youtube_thumbnail(url):
 
535
  def subtify():
536
  with gr.Blocks() as demo:
537
  num_speaker = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]
 
 
 
 
 
538
 
539
  # Layout
540
  gr.Markdown(html_social_media)
541
  gr.Markdown("<h1 style='text-align: center;'>Subtify</h1>")
542
+ gr.Markdown(html_subtify_logo)
543
  with gr.Row(variant="panel"):
544
  url_textbox = gr.Textbox(placeholder="Add video URL here", label="Video URL", elem_id="video_url", scale=1, interactive=True)
545
  # copy_button = gr.Button(size="sm", icon="icons/copy.svg", value="", min_width="10px", scale=0)
 
636
  outputs=[video_subtitled_progress_info, subtitled_video]
637
  )
638
 
639
+ gr.Markdown(html_buy_me_a_coffe)
640
+
641
  demo.launch()
642
 
643