Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -94,17 +94,17 @@ with gr.Blocks(css=custom_css) as demo:
|
|
94 |
# Étape 2 : Gestion des Sections
|
95 |
sections = []
|
96 |
|
97 |
-
def add_section():
|
98 |
section_name = f"Section {len(sections) + 1}"
|
99 |
sections.append({"name": section_name, "text": ""})
|
100 |
return sections
|
101 |
|
102 |
-
def remove_section(
|
103 |
-
if
|
104 |
-
sections.pop(
|
105 |
return sections
|
106 |
|
107 |
-
def update_section_text(index, text):
|
108 |
if index < len(sections):
|
109 |
sections[index]["text"] = text
|
110 |
return sections
|
@@ -116,7 +116,7 @@ with gr.Blocks(css=custom_css) as demo:
|
|
116 |
|
117 |
def render_sections(sections):
|
118 |
return [gr.Row([
|
119 |
-
gr.Textbox(label=f"Texte pour {section['name']}", value=section['text'], lines=5).change(update_section_text, inputs=[sections.index(section)], outputs=None),
|
120 |
gr.Textbox(label="Nom du fichier", value=section['name'], interactive=False),
|
121 |
gr.Button("Régénérer", variant="secondary").click(generate_audio, inputs=[section['text'], speaker, project_folder, section['name']], outputs=[gr.Audio(label=f"Audio {section['name']}")])
|
122 |
]) for section in sections]
|
@@ -125,8 +125,8 @@ with gr.Blocks(css=custom_css) as demo:
|
|
125 |
add_section_btn = gr.Button("+ Ajouter une section")
|
126 |
remove_section_btn = gr.Button("- Supprimer la dernière section")
|
127 |
|
128 |
-
add_section_btn.click(add_section, outputs=section_list)
|
129 |
-
remove_section_btn.click(remove_section, inputs=[
|
130 |
|
131 |
section_output_area = gr.Column()
|
132 |
|
|
|
94 |
# Étape 2 : Gestion des Sections
|
95 |
sections = []
|
96 |
|
97 |
+
def add_section(sections):
|
98 |
section_name = f"Section {len(sections) + 1}"
|
99 |
sections.append({"name": section_name, "text": ""})
|
100 |
return sections
|
101 |
|
102 |
+
def remove_section(sections):
|
103 |
+
if sections:
|
104 |
+
sections.pop()
|
105 |
return sections
|
106 |
|
107 |
+
def update_section_text(index, text, sections):
|
108 |
if index < len(sections):
|
109 |
sections[index]["text"] = text
|
110 |
return sections
|
|
|
116 |
|
117 |
def render_sections(sections):
|
118 |
return [gr.Row([
|
119 |
+
gr.Textbox(label=f"Texte pour {section['name']}", value=section['text'], lines=5).change(update_section_text, inputs=[sections.index(section), _, section_list], outputs=None),
|
120 |
gr.Textbox(label="Nom du fichier", value=section['name'], interactive=False),
|
121 |
gr.Button("Régénérer", variant="secondary").click(generate_audio, inputs=[section['text'], speaker, project_folder, section['name']], outputs=[gr.Audio(label=f"Audio {section['name']}")])
|
122 |
]) for section in sections]
|
|
|
125 |
add_section_btn = gr.Button("+ Ajouter une section")
|
126 |
remove_section_btn = gr.Button("- Supprimer la dernière section")
|
127 |
|
128 |
+
add_section_btn.click(add_section, inputs=[section_list], outputs=section_list)
|
129 |
+
remove_section_btn.click(remove_section, inputs=[section_list], outputs=section_list)
|
130 |
|
131 |
section_output_area = gr.Column()
|
132 |
|