RohitCSharp commited on
Commit
cd2f783
·
verified ·
1 Parent(s): 2d955c8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -4
app.py CHANGED
@@ -15,7 +15,7 @@ UNSPLASH_KEY = "-7tFgMCy_pwrouZrC8mmEIBpyskEyP25e3_Y4vWSvBs"
15
 
16
  llm = ChatOpenAI(model="gpt-3.5-turbo", temperature=0.3)
17
  summary_prompt = PromptTemplate.from_template("""
18
- Provide a crisp, promotional-style summary (under 50 words) of the following:
19
 
20
  {text}
21
 
@@ -40,7 +40,11 @@ def fetch_unsplash_image(query):
40
 
41
  ASSETS = {
42
  "logo": "https://huggingface.co/spaces/csccorner/Link-to-video/resolve/main/csharplogo.png",
43
- "illustration": "https://img.freepik.com/free-vector/startup-launch-concept-with-rocket_23-2147866180.jpg"
 
 
 
 
44
  }
45
 
46
  def download_asset(url):
@@ -52,7 +56,6 @@ def create_slides(text, duration, output_folder, max_lines=6):
52
  font_path = "/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf"
53
  font = ImageFont.truetype(font_path, 48)
54
  logo_path = download_asset(ASSETS["logo"])
55
- graphic_path = download_asset(ASSETS["illustration"])
56
 
57
  chunks = textwrap.wrap(text, width=36)
58
  slides = ["\n".join(chunks[i:i+max_lines]) for i in range(0, len(chunks), max_lines)]
@@ -62,6 +65,7 @@ def create_slides(text, duration, output_folder, max_lines=6):
62
  for i, slide_text in enumerate(slides):
63
  query = random.choice(slide_text.split())
64
  bg_path = download_asset(fetch_unsplash_image(query))
 
65
 
66
  bg = Image.open(bg_path).resize((1280, 720)).convert("RGBA")
67
  enhancer = ImageEnhance.Brightness(bg)
@@ -137,7 +141,7 @@ iface = gr.Interface(
137
  gr.Video(label="Generated AV Summary")
138
  ],
139
  title="🎮 AV Summary Generator (Visual Promo Style)",
140
- description="Generates a 5/10 sec video summary from article URL with clean typography, visuals, logo and illustration."
141
  )
142
 
143
  if __name__ == '__main__':
 
15
 
16
  llm = ChatOpenAI(model="gpt-3.5-turbo", temperature=0.3)
17
  summary_prompt = PromptTemplate.from_template("""
18
+ Provide a crisp, promotional-style summary (under 100 words) of the following:
19
 
20
  {text}
21
 
 
40
 
41
  ASSETS = {
42
  "logo": "https://huggingface.co/spaces/csccorner/Link-to-video/resolve/main/csharplogo.png",
43
+ "graphics": [
44
+ "https://img.freepik.com/free-vector/startup-launch-concept-with-rocket_23-2147866180.jpg",
45
+ "https://img.freepik.com/free-vector/artificial-intelligence-concept-illustration_114360-7307.jpg",
46
+ "https://img.freepik.com/free-vector/business-goal-achievement-banner_33099-1687.jpg"
47
+ ]
48
  }
49
 
50
  def download_asset(url):
 
56
  font_path = "/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf"
57
  font = ImageFont.truetype(font_path, 48)
58
  logo_path = download_asset(ASSETS["logo"])
 
59
 
60
  chunks = textwrap.wrap(text, width=36)
61
  slides = ["\n".join(chunks[i:i+max_lines]) for i in range(0, len(chunks), max_lines)]
 
65
  for i, slide_text in enumerate(slides):
66
  query = random.choice(slide_text.split())
67
  bg_path = download_asset(fetch_unsplash_image(query))
68
+ graphic_path = download_asset(random.choice(ASSETS["graphics"]))
69
 
70
  bg = Image.open(bg_path).resize((1280, 720)).convert("RGBA")
71
  enhancer = ImageEnhance.Brightness(bg)
 
141
  gr.Video(label="Generated AV Summary")
142
  ],
143
  title="🎮 AV Summary Generator (Visual Promo Style)",
144
+ description="Generates a 5/10 sec video summary from article URL with clean typography, visuals, C# Corner logo, and themed illustrations."
145
  )
146
 
147
  if __name__ == '__main__':