Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import gradio as gr
|
3 |
+
from transformers import pipeline
|
4 |
+
from pptx import Presentation
|
5 |
+
from pptx.util import Inches
|
6 |
+
|
7 |
+
# Chargement du modèle IA depuis Hugging Face
|
8 |
+
text_to_presentation = pipeline("text-generation", model="your-model-on-huggingface")
|
9 |
+
|
10 |
+
def generate_presentation(text):
|
11 |
+
# Analyse du texte avec le modèle IA
|
12 |
+
presentation_content = text_to_presentation(text, max_length=1500, num_return_sequences=1)[0]["generated_text"]
|
13 |
+
|
14 |
+
# Génération de la présentation PowerPoint
|
15 |
+
prs = Presentation()
|
16 |
+
slide = prs.slides.add_slide(prs.slide_layouts[0])
|
17 |
+
title = slide.shapes.title
|
18 |
+
title.text = "Présentation générée"
|
19 |
+
body = slide.placeholders[1].text_frame
|
20 |
+
body.text = presentation_content
|
21 |
+
|
22 |
+
# Enregistrement de la présentation
|
23 |
+
prs.save("presentation.pptx")
|
24 |
+
|
25 |
+
# Retourner le lien de téléchargement
|
26 |
+
return "Votre présentation est prête ! Vous pouvez la télécharger ici : " + os.path.abspath("presentation.pptx")
|
27 |
+
|
28 |
+
# Interface Gradio
|
29 |
+
demo = gr.Interface(
|
30 |
+
fn=generate_presentation,
|
31 |
+
inputs="text",
|
32 |
+
outputs="text",
|
33 |
+
title="Générateur de présentations",
|
34 |
+
description="Entrez du texte et obtenez une présentation PowerPoint générée automatiquement."
|
35 |
+
)
|
36 |
+
|
37 |
+
if __name__ == "__main__":
|
38 |
+
demo.launch()
|