RohitCSharp commited on
Commit
6e4263d
·
verified ·
1 Parent(s): 1799bb4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -9
app.py CHANGED
@@ -28,19 +28,19 @@ def extract_main_content(url):
28
  paras = [p.get_text() for p in soup.find_all("p") if len(p.get_text()) > 60]
29
  return "\n".join(paras[:20]) or None
30
 
31
- # Download C# Corner logo
32
- LOGO_URL = "https://csharpcorner-mindcrackerinc.netdna-ssl.com/App_Themes/Default/images/c-sharp-corner-logo.png"
33
- def download_logo():
34
  logo_path = tempfile.NamedTemporaryFile(delete=False, suffix=".png").name
35
- with open(logo_path, 'wb') as f:
36
- f.write(requests.get(LOGO_URL).content)
37
  return logo_path
38
 
39
  # Create image slides from text chunks
40
  def create_slides(text, duration, output_folder, max_lines=6):
41
  font_path = "/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf"
42
  font = ImageFont.truetype(font_path, 48)
43
- logo_path = download_logo()
44
 
45
  chunks = textwrap.wrap(text, width=40)
46
  slides = ["\n".join(chunks[i:i+max_lines]) for i in range(0, len(chunks), max_lines)]
@@ -114,9 +114,9 @@ iface = gr.Interface(
114
  gr.Textbox(label="Summary"),
115
  gr.Video(label="Generated AV Summary")
116
  ],
117
- title="🎞️ AV Summary Generator (Multislide with Logo)",
118
- description="Generates a 5/10 sec video summary from article URL with large text, logo, and slide animation."
119
  )
120
 
121
  if __name__ == '__main__':
122
- iface.launch()
 
28
  paras = [p.get_text() for p in soup.find_all("p") if len(p.get_text()) > 60]
29
  return "\n".join(paras[:20]) or None
30
 
31
+ # Convert uploaded PNG logo to local use (as SVG substitute if needed)
32
+ def get_uploaded_logo():
33
+ from_path = "/mnt/data/CSHARP logo.png"
34
  logo_path = tempfile.NamedTemporaryFile(delete=False, suffix=".png").name
35
+ with open(from_path, 'rb') as src, open(logo_path, 'wb') as dst:
36
+ dst.write(src.read())
37
  return logo_path
38
 
39
  # Create image slides from text chunks
40
  def create_slides(text, duration, output_folder, max_lines=6):
41
  font_path = "/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf"
42
  font = ImageFont.truetype(font_path, 48)
43
+ logo_path = get_uploaded_logo()
44
 
45
  chunks = textwrap.wrap(text, width=40)
46
  slides = ["\n".join(chunks[i:i+max_lines]) for i in range(0, len(chunks), max_lines)]
 
114
  gr.Textbox(label="Summary"),
115
  gr.Video(label="Generated AV Summary")
116
  ],
117
+ title="🎞️ AV Summary Generator (Multislide with Uploaded Logo)",
118
+ description="Generates a 5/10 sec video summary from article URL with large text, uploaded logo, and slide animation."
119
  )
120
 
121
  if __name__ == '__main__':
122
+ iface.launch()