RohitCSharp commited on
Commit
34d472d
·
verified ·
1 Parent(s): 17cac71

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -7
app.py CHANGED
@@ -30,10 +30,11 @@ def extract_main_content(url):
30
  paras = [p.get_text() for p in soup.find_all("p") if len(p.get_text()) > 60]
31
  return "\n".join(paras[:20]) or None
32
 
33
- # Load external image assets like logo or graphics from URL
34
  ASSETS = {
35
- "logo": "./files/CSHARP logo.png", # Free C# Corner-style logo
36
- "bg": "https://img.freepik.com/free-photo/blue-abstract-gradient-wave-wallpaper_53876-102605.jpg"
 
37
  }
38
 
39
  def download_asset(url):
@@ -47,6 +48,7 @@ def create_slides(text, duration, output_folder, max_lines=6):
47
  font = ImageFont.truetype(font_path, 48)
48
  logo_path = download_asset(ASSETS["logo"])
49
  bg_path = download_asset(ASSETS["bg"])
 
50
 
51
  chunks = textwrap.wrap(text, width=36)
52
  slides = ["\n".join(chunks[i:i+max_lines]) for i in range(0, len(chunks), max_lines)]
@@ -70,7 +72,11 @@ def create_slides(text, duration, output_folder, max_lines=6):
70
  logo_width = min(180, int(0.15 * bg.width))
71
  logo_height = int(logo.size[1] * (logo_width / logo.size[0]))
72
  logo = logo.resize((logo_width, logo_height))
73
- bg.paste(logo, (bg.width - logo_width - 30, bg.height - logo_height - 30), logo)
 
 
 
 
74
 
75
  frame_path = os.path.join(output_folder, f"slide_{i}.png")
76
  bg.convert("RGB").save(frame_path)
@@ -124,9 +130,9 @@ iface = gr.Interface(
124
  gr.Textbox(label="Summary"),
125
  gr.Video(label="Generated AV Summary")
126
  ],
127
- title="🎞️ AV Summary Generator (Enhanced Slides with Background & Logo)",
128
- description="Generates a 5/10 sec video summary from article URL with clean text, background visuals, logo, and better visuals."
129
  )
130
 
131
  if __name__ == '__main__':
132
- iface.launch()
 
30
  paras = [p.get_text() for p in soup.find_all("p") if len(p.get_text()) > 60]
31
  return "\n".join(paras[:20]) or None
32
 
33
+ # Load external image assets
34
  ASSETS = {
35
+ "logo": "https://huggingface.co/spaces/csccorner/Link-to-video/resolve/main/csharplogo.png",
36
+ "bg": "https://img.freepik.com/free-photo/blue-abstract-gradient-wave-wallpaper_53876-102605.jpg",
37
+ "graphic": "https://img.freepik.com/free-vector/startup-launch-concept-with-rocket_23-2147866180.jpg"
38
  }
39
 
40
  def download_asset(url):
 
48
  font = ImageFont.truetype(font_path, 48)
49
  logo_path = download_asset(ASSETS["logo"])
50
  bg_path = download_asset(ASSETS["bg"])
51
+ graphic_path = download_asset(ASSETS["graphic"])
52
 
53
  chunks = textwrap.wrap(text, width=36)
54
  slides = ["\n".join(chunks[i:i+max_lines]) for i in range(0, len(chunks), max_lines)]
 
72
  logo_width = min(180, int(0.15 * bg.width))
73
  logo_height = int(logo.size[1] * (logo_width / logo.size[0]))
74
  logo = logo.resize((logo_width, logo_height))
75
+ bg.paste(logo, (30, 30), logo)
76
+
77
+ graphic = Image.open(graphic_path).convert("RGBA")
78
+ graphic = graphic.resize((240, 240))
79
+ bg.paste(graphic, (bg.width - 270, 30), graphic)
80
 
81
  frame_path = os.path.join(output_folder, f"slide_{i}.png")
82
  bg.convert("RGB").save(frame_path)
 
130
  gr.Textbox(label="Summary"),
131
  gr.Video(label="Generated AV Summary")
132
  ],
133
+ title="🎞️ AV Summary Generator (Enhanced Slides with Background, Logo & Graphics)",
134
+ description="Generates a 5/10 sec video summary from article URL with clean text, background visuals, C# Corner logo, and graphics."
135
  )
136
 
137
  if __name__ == '__main__':
138
+ iface.launch()