Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -38,11 +38,14 @@ def generate_section_audio(project_name, section_name, text, speaker):
|
|
| 38 |
except Exception as e:
|
| 39 |
return str(e) # Retourne l'erreur pour gestion dans l'interface
|
| 40 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
# Interface Gradio
|
| 42 |
with gr.Blocks() as demo:
|
| 43 |
-
#
|
| 44 |
-
|
| 45 |
-
sections = gr.State(value=[]) # Liste dynamique des sections ajoutées
|
| 46 |
|
| 47 |
# Introduction et explication globale
|
| 48 |
gr.Markdown("""
|
|
@@ -59,7 +62,6 @@ with gr.Blocks() as demo:
|
|
| 59 |
# Étape 1 : Création du Projet
|
| 60 |
with gr.Row(visible=True) as step1:
|
| 61 |
gr.Markdown("### 🛠️ Étape 1 : Création du Projet")
|
| 62 |
-
gr.Markdown("**📂 Définissez les informations générales pour votre projet.**")
|
| 63 |
project_name = gr.Textbox(label="Nom du Projet", placeholder="Exemple : Capsule_Video_PLU")
|
| 64 |
speaker = gr.Dropdown(label="Voix 🎙️", choices=["Margaux"], value="Margaux") # Liste de voix
|
| 65 |
agree = gr.Checkbox(label="✅ J'accepte les conditions d'utilisation")
|
|
@@ -81,7 +83,7 @@ with gr.Blocks() as demo:
|
|
| 81 |
prev_btn_2 = gr.Button("⬅️ Précédent")
|
| 82 |
next_btn_2 = gr.Button("Suivant ➡️")
|
| 83 |
|
| 84 |
-
# Étape 3 : Génération des Audios et
|
| 85 |
with gr.Row(visible=False) as step3:
|
| 86 |
gr.Markdown("### 🎧 Étape 3 : Génération et Gestion des Audios")
|
| 87 |
gr.Markdown("""
|
|
@@ -106,7 +108,7 @@ with gr.Blocks() as demo:
|
|
| 106 |
next_btn_1.click(
|
| 107 |
create_project,
|
| 108 |
inputs=[project_name, speaker, agree],
|
| 109 |
-
outputs=[project_message,
|
| 110 |
)
|
| 111 |
|
| 112 |
def add_section(sections):
|
|
@@ -135,15 +137,12 @@ with gr.Blocks() as demo:
|
|
| 135 |
generate_btn.click(
|
| 136 |
generate_audios,
|
| 137 |
inputs=[project_name, sections, speaker],
|
| 138 |
-
outputs=[results_output]
|
| 139 |
)
|
| 140 |
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
prev_btn_3.click(lambda: 2, inputs=None, outputs=step)
|
| 146 |
-
save_project_btn.click(lambda: "🎉 Projet sauvegardé avec succès !", outputs=[project_message])
|
| 147 |
|
| 148 |
# Lancement de l'interface
|
| 149 |
demo.launch(debug=True)
|
|
|
|
| 38 |
except Exception as e:
|
| 39 |
return str(e) # Retourne l'erreur pour gestion dans l'interface
|
| 40 |
|
| 41 |
+
# Fonction pour gérer la visibilité des étapes
|
| 42 |
+
def update_steps(current_step, target_step):
|
| 43 |
+
return {"visible": target_step == 1}, {"visible": target_step == 2}, {"visible": target_step == 3}
|
| 44 |
+
|
| 45 |
# Interface Gradio
|
| 46 |
with gr.Blocks() as demo:
|
| 47 |
+
# Liste dynamique des sections
|
| 48 |
+
sections = gr.State(value=[])
|
|
|
|
| 49 |
|
| 50 |
# Introduction et explication globale
|
| 51 |
gr.Markdown("""
|
|
|
|
| 62 |
# Étape 1 : Création du Projet
|
| 63 |
with gr.Row(visible=True) as step1:
|
| 64 |
gr.Markdown("### 🛠️ Étape 1 : Création du Projet")
|
|
|
|
| 65 |
project_name = gr.Textbox(label="Nom du Projet", placeholder="Exemple : Capsule_Video_PLU")
|
| 66 |
speaker = gr.Dropdown(label="Voix 🎙️", choices=["Margaux"], value="Margaux") # Liste de voix
|
| 67 |
agree = gr.Checkbox(label="✅ J'accepte les conditions d'utilisation")
|
|
|
|
| 83 |
prev_btn_2 = gr.Button("⬅️ Précédent")
|
| 84 |
next_btn_2 = gr.Button("Suivant ➡️")
|
| 85 |
|
| 86 |
+
# Étape 3 : Génération des Audios et Sauvegarde
|
| 87 |
with gr.Row(visible=False) as step3:
|
| 88 |
gr.Markdown("### 🎧 Étape 3 : Génération et Gestion des Audios")
|
| 89 |
gr.Markdown("""
|
|
|
|
| 108 |
next_btn_1.click(
|
| 109 |
create_project,
|
| 110 |
inputs=[project_name, speaker, agree],
|
| 111 |
+
outputs=[project_message, step1],
|
| 112 |
)
|
| 113 |
|
| 114 |
def add_section(sections):
|
|
|
|
| 137 |
generate_btn.click(
|
| 138 |
generate_audios,
|
| 139 |
inputs=[project_name, sections, speaker],
|
| 140 |
+
outputs=[results_output],
|
| 141 |
)
|
| 142 |
|
| 143 |
+
prev_btn_2.click(lambda: update_steps(2, 1), inputs=None, outputs=[step1, step2, step3])
|
| 144 |
+
next_btn_2.click(lambda: update_steps(2, 3), inputs=None, outputs=[step1, step2, step3])
|
| 145 |
+
prev_btn_3.click(lambda: update_steps(3, 2), inputs=None, outputs=[step1, step2, step3])
|
|
|
|
|
|
|
|
|
|
| 146 |
|
| 147 |
# Lancement de l'interface
|
| 148 |
demo.launch(debug=True)
|