fizzarif7 commited on
Commit
185c35f
Β·
verified Β·
1 Parent(s): 24fdf22

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -10
app.py CHANGED
@@ -78,12 +78,8 @@ def generate_pdf(images, explanations, title="AI-Generated Story Scenes"):
78
  with tempfile.NamedTemporaryFile(delete=False, suffix=".pdf") as tmp:
79
  doc = SimpleDocTemplate(tmp.name, pagesize=letter)
80
  styles = getSampleStyleSheet()
81
-
82
- # Add the title at the top
83
- story = [
84
- Paragraph(title, styles["Title"]),
85
- Spacer(1, 24)
86
- ]
87
 
88
  for i, img in enumerate(images):
89
  if img:
@@ -137,7 +133,7 @@ def finalize_story(images, explanations, title):
137
  if not images or not explanations:
138
  return None, None
139
 
140
- pdf = generate_pdf(images, explanations, title=title)
141
 
142
  with tempfile.NamedTemporaryFile(delete=False, suffix=".txt", mode="w", encoding="utf-8") as txt:
143
  for i, exp in enumerate(explanations):
@@ -146,7 +142,6 @@ def finalize_story(images, explanations, title):
146
 
147
  return txt_path, pdf
148
 
149
-
150
  def ai_write_scene(theme, total_scenes, scene_summaries):
151
  try:
152
  scene_index = len(scene_summaries) + 1
@@ -321,6 +316,7 @@ with gr.Blocks(
321
  gr.Markdown("Describe your story one scene at a time, with AI-generated images, summaries, and explanations.")
322
 
323
  with gr.Accordion("🧩 Story Setup", open=True):
 
324
  scene_total = gr.Number(label="πŸ”’ Number of Scenes", precision=0, value=3, elem_id="scene-count")
325
  theme = gr.Textbox(label="🌍 Global Theme", placeholder="e.g. A magical forest full of glowing creatures", elem_id="theme-input")
326
 
@@ -413,9 +409,10 @@ with gr.Blocks(
413
 
414
  done_btn.click(
415
  fn=finalize_story,
416
- inputs=[scene_images, scene_explanations, theme],
417
  outputs=[txt_file, pdf_file]
418
- )
 
419
 
420
 
421
  tts_btn.click(
 
78
  with tempfile.NamedTemporaryFile(delete=False, suffix=".pdf") as tmp:
79
  doc = SimpleDocTemplate(tmp.name, pagesize=letter)
80
  styles = getSampleStyleSheet()
81
+ story = [Paragraph(title, styles["Title"]), Spacer(1, 12)]
82
+
 
 
 
 
83
 
84
  for i, img in enumerate(images):
85
  if img:
 
133
  if not images or not explanations:
134
  return None, None
135
 
136
+ pdf = generate_pdf(images, explanations,title)
137
 
138
  with tempfile.NamedTemporaryFile(delete=False, suffix=".txt", mode="w", encoding="utf-8") as txt:
139
  for i, exp in enumerate(explanations):
 
142
 
143
  return txt_path, pdf
144
 
 
145
  def ai_write_scene(theme, total_scenes, scene_summaries):
146
  try:
147
  scene_index = len(scene_summaries) + 1
 
316
  gr.Markdown("Describe your story one scene at a time, with AI-generated images, summaries, and explanations.")
317
 
318
  with gr.Accordion("🧩 Story Setup", open=True):
319
+ title = gr.Textbox(label="πŸ“– Story Title", placeholder="e.g. The Enchanted Forest")
320
  scene_total = gr.Number(label="πŸ”’ Number of Scenes", precision=0, value=3, elem_id="scene-count")
321
  theme = gr.Textbox(label="🌍 Global Theme", placeholder="e.g. A magical forest full of glowing creatures", elem_id="theme-input")
322
 
 
409
 
410
  done_btn.click(
411
  fn=finalize_story,
412
+ inputs=[scene_images, scene_explanations, title],
413
  outputs=[txt_file, pdf_file]
414
+ )
415
+
416
 
417
 
418
  tts_btn.click(