amagastya commited on
Commit
bf31004
Β·
verified Β·
1 Parent(s): b96fdff

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +39 -10
app.py CHANGED
@@ -100,7 +100,7 @@ def countdown_loader(duration=75):
100
  progress = (duration - remaining) / duration
101
  placeholder.text(f"⏳ Generating video... Estimated time remaining: {remaining} seconds")
102
  progress_bar.progress(progress)
103
- time.sleep(1) # Uncomment this to ensure real-time updates
104
 
105
  placeholder.empty() # Clear the placeholder after countdown
106
  return placeholder, progress_bar
@@ -130,6 +130,13 @@ def create_task_callback(task_config, status_container, progress_bar, progress_v
130
  return output
131
  return callback
132
 
 
 
 
 
 
 
 
133
  def main():
134
  # Initialize all session state variables
135
  if 'video_path' not in st.session_state:
@@ -166,13 +173,13 @@ def main():
166
  st.info("""
167
  πŸ’‘ **What is a Sizzle Reel?**
168
 
169
- A sizzle reel is a fast-paced, high-energy promotional video that
170
- captures the essence of your app in 60-90 seconds. It's designed
171
- to grab attention, showcase key features, and leave a lasting
172
  impression on potential users or investors.
173
  """)
174
 
175
- # Random Generator Button - In the middle
176
  st.write("Need inspiration? Try a random app idea:")
177
  if st.button("🎲 Generate Random App", key="random_app_button", use_container_width=True):
178
  selected_app = random.choice(APP_IDEAS_WITH_NAMES)
@@ -186,6 +193,7 @@ def main():
186
  else:
187
  st.session_state.cached_content = None
188
 
 
189
  st.rerun()
190
 
191
  # App Name Input
@@ -205,11 +213,29 @@ def main():
205
  )
206
 
207
  # Generate Script Button
208
- if st.button("Generate Sizzle Reel Script", type="primary"):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
209
  # Update session state with latest input values
210
  st.session_state.app_name = app_name
211
  st.session_state.customer_idea = customer_idea
212
-
213
  inputs = {
214
  "app_name": st.session_state.app_name,
215
  "customer_idea": st.session_state.customer_idea,
@@ -235,15 +261,15 @@ def main():
235
  # Show progress with minimal delays
236
  hero_status.write("πŸ•΅οΈ Hero Research Specialist: Analyzing...")
237
  progress_bar.progress(33)
238
- time.sleep(0.5)
239
 
240
  content_status.write("πŸ“ Narrative Architect: Creating content...")
241
  progress_bar.progress(66)
242
- time.sleep(0.5)
243
 
244
  script_status_placeholder.write("🎬 Script Writer: Finalizing...")
245
  progress_bar.progress(90)
246
- time.sleep(0.5)
247
 
248
  script_status.update(label="Script Generated! βœ…", state="complete", expanded=False)
249
 
@@ -301,18 +327,21 @@ def main():
301
  # Hero Research Task
302
  hero_status.write("�️ Hero Research Specialist: Analyzing hero user journey...")
303
  progress_bar.progress(20)
 
304
  hero_status.write("🎯 Hero Research Specialist: Uncovering user persona and journey insights for the app...")
305
  progress_bar.progress(33)
306
  elif task_index == 1:
307
  # Content Strategy Task
308
  content_status.write("πŸ“Š Narrative Architect: Creating content strategy...")
309
  progress_bar.progress(45)
 
310
  content_status.write("✍️ Narrative Architect: Crafting a compelling narrative...")
311
  progress_bar.progress(66)
312
  elif task_index == 2:
313
  # Script Generation Task
314
  script_status_placeholder.write("✍️ Script Writer: Writing final script...")
315
  progress_bar.progress(80)
 
316
  script_status_placeholder.write("🎬 Script Writer: Transforming insights into an engaging sizzle reel script...")
317
  progress_bar.progress(90)
318
  return output
 
100
  progress = (duration - remaining) / duration
101
  placeholder.text(f"⏳ Generating video... Estimated time remaining: {remaining} seconds")
102
  progress_bar.progress(progress)
103
+ time.sleep(1.2) # Uncomment this to ensure real-time updates
104
 
105
  placeholder.empty() # Clear the placeholder after countdown
106
  return placeholder, progress_bar
 
130
  return output
131
  return callback
132
 
133
+ def generate_random_app():
134
+ selected_app = random.choice(APP_IDEAS_WITH_NAMES)
135
+ st.session_state.app_name = selected_app["name"]
136
+ st.session_state.customer_idea = selected_app["idea"]
137
+ # Add this to automatically trigger the generate button
138
+ st.session_state.generate_clicked = True
139
+
140
  def main():
141
  # Initialize all session state variables
142
  if 'video_path' not in st.session_state:
 
173
  st.info("""
174
  πŸ’‘ **What is a Sizzle Reel?**
175
 
176
+ A sizzle reel is a short, captivating promotional video designed to showcase your app’s unique features, value, and vision.
177
+
178
+ It's designed to grab attention, and leave a lasting
179
  impression on potential users or investors.
180
  """)
181
 
182
+ # Random Generator Button - In the middle
183
  st.write("Need inspiration? Try a random app idea:")
184
  if st.button("🎲 Generate Random App", key="random_app_button", use_container_width=True):
185
  selected_app = random.choice(APP_IDEAS_WITH_NAMES)
 
193
  else:
194
  st.session_state.cached_content = None
195
 
196
+ st.session_state.auto_generate = True # Set flag to trigger auto-generation
197
  st.rerun()
198
 
199
  # App Name Input
 
213
  )
214
 
215
  # Generate Script Button
216
+ # Check if auto_generate flag is set or button is pressed
217
+ auto_generate = st.session_state.pop("auto_generate", False) if "auto_generate" in st.session_state else False
218
+ generate_clicked = st.button("Generate Sizzle Reel", type="primary")
219
+
220
+ # --- NEW LOGIC: If user clicks generate with empty fields, trigger random app and rerun ---
221
+ if generate_clicked and (not app_name.strip() or not customer_idea.strip()):
222
+ selected_app = random.choice(APP_IDEAS_WITH_NAMES)
223
+ st.session_state.app_name = selected_app["name"]
224
+ st.session_state.customer_idea = selected_app["idea"]
225
+ cached_content = get_cached_content(selected_app["name"])
226
+ if cached_content:
227
+ st.session_state.cached_content = cached_content
228
+ else:
229
+ st.session_state.cached_content = None
230
+ st.session_state.auto_generate = True
231
+ st.rerun()
232
+ # --- END NEW LOGIC ---
233
+
234
+ if (generate_clicked or auto_generate) and app_name.strip() and customer_idea.strip():
235
  # Update session state with latest input values
236
  st.session_state.app_name = app_name
237
  st.session_state.customer_idea = customer_idea
238
+
239
  inputs = {
240
  "app_name": st.session_state.app_name,
241
  "customer_idea": st.session_state.customer_idea,
 
261
  # Show progress with minimal delays
262
  hero_status.write("πŸ•΅οΈ Hero Research Specialist: Analyzing...")
263
  progress_bar.progress(33)
264
+ time.sleep(1.2) # <-- changed from 0.5 to 1
265
 
266
  content_status.write("πŸ“ Narrative Architect: Creating content...")
267
  progress_bar.progress(66)
268
+ time.sleep(1.2) # <-- changed from 0.5 to 1
269
 
270
  script_status_placeholder.write("🎬 Script Writer: Finalizing...")
271
  progress_bar.progress(90)
272
+ time.sleep(1.2) # <-- changed from 0.5 to 1
273
 
274
  script_status.update(label="Script Generated! βœ…", state="complete", expanded=False)
275
 
 
327
  # Hero Research Task
328
  hero_status.write("�️ Hero Research Specialist: Analyzing hero user journey...")
329
  progress_bar.progress(20)
330
+ time.sleep(2) # Give time to read
331
  hero_status.write("🎯 Hero Research Specialist: Uncovering user persona and journey insights for the app...")
332
  progress_bar.progress(33)
333
  elif task_index == 1:
334
  # Content Strategy Task
335
  content_status.write("πŸ“Š Narrative Architect: Creating content strategy...")
336
  progress_bar.progress(45)
337
+ time.sleep(2) # Give time to read
338
  content_status.write("✍️ Narrative Architect: Crafting a compelling narrative...")
339
  progress_bar.progress(66)
340
  elif task_index == 2:
341
  # Script Generation Task
342
  script_status_placeholder.write("✍️ Script Writer: Writing final script...")
343
  progress_bar.progress(80)
344
+ time.sleep(2) # Give time to read
345
  script_status_placeholder.write("🎬 Script Writer: Transforming insights into an engaging sizzle reel script...")
346
  progress_bar.progress(90)
347
  return output