Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -63,7 +63,35 @@ def generate_presentation_content(topic, client, max_retries=3):
|
|
| 63 |
|
| 64 |
return None
|
| 65 |
|
| 66 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
|
| 68 |
def main():
|
| 69 |
st.title("Generador de presentaciones PowerPoint con IA")
|
|
|
|
| 63 |
|
| 64 |
return None
|
| 65 |
|
| 66 |
+
def create_powerpoint(slides, template_path):
|
| 67 |
+
prs = Presentation(template_path)
|
| 68 |
+
|
| 69 |
+
for slide_data in slides:
|
| 70 |
+
slide = prs.slides.add_slide(prs.slide_layouts[1])
|
| 71 |
+
|
| 72 |
+
title_shape = slide.shapes.title
|
| 73 |
+
content_shape = slide.placeholders[1]
|
| 74 |
+
|
| 75 |
+
if title_shape:
|
| 76 |
+
title_shape.text = slide_data['title']
|
| 77 |
+
|
| 78 |
+
if content_shape:
|
| 79 |
+
content_shape.text = slide_data['content']
|
| 80 |
+
else:
|
| 81 |
+
# Si no hay un placeholder para el contenido, añadimos un cuadro de texto
|
| 82 |
+
left = Inches(0.5)
|
| 83 |
+
top = Inches(1.5)
|
| 84 |
+
width = Inches(9)
|
| 85 |
+
height = Inches(5)
|
| 86 |
+
txBox = slide.shapes.add_textbox(left, top, width, height)
|
| 87 |
+
tf = txBox.text_frame
|
| 88 |
+
tf.text = slide_data['content']
|
| 89 |
+
|
| 90 |
+
pptx_buffer = io.BytesIO()
|
| 91 |
+
prs.save(pptx_buffer)
|
| 92 |
+
pptx_buffer.seek(0)
|
| 93 |
+
|
| 94 |
+
return pptx_buffer
|
| 95 |
|
| 96 |
def main():
|
| 97 |
st.title("Generador de presentaciones PowerPoint con IA")
|