Woziii commited on
Commit
c6e52e2
·
verified ·
1 Parent(s): 328d70f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -5
app.py CHANGED
@@ -2,7 +2,6 @@ import subprocess
2
  import os
3
  import gradio as gr
4
  from TTS.api import TTS
5
-
6
  # Initialisation du modèle TTS
7
  tts = TTS("tts_models/multilingual/multi-dataset/xtts_v2", gpu=False)
8
 
@@ -142,13 +141,22 @@ with gr.Blocks(css=custom_css) as demo:
142
  remove_section_btn = gr.Button("- Supprimer une section")
143
 
144
  add_section_btn.click(add_section)
145
- remove_section_btn.click(remove_section)
 
 
 
 
 
 
 
 
 
146
 
147
  generate_audio_btn = gr.Button("Générer l'audio")
148
 
149
- def generate_all_sections(sections_data, proj_folder):
150
  audio_outputs = []
151
- for text_box, name_box in sections_data:
152
  text = text_box.value
153
  name = name_box.value
154
  audio_path = generate_audio_section(text, name.strip(), proj_folder.value, speaker.value)
@@ -159,7 +167,7 @@ with gr.Blocks(css=custom_css) as demo:
159
 
160
  generate_audio_btn.click(
161
  generate_all_sections,
162
- inputs=[section_textboxes, project_folder_output],
163
  outputs=audio_outputs_display
164
  )
165
 
 
2
  import os
3
  import gradio as gr
4
  from TTS.api import TTS
 
5
  # Initialisation du modèle TTS
6
  tts = TTS("tts_models/multilingual/multi-dataset/xtts_v2", gpu=False)
7
 
 
141
  remove_section_btn = gr.Button("- Supprimer une section")
142
 
143
  add_section_btn.click(add_section)
144
+
145
+ # Outputs for the sections
146
+ added_sections_output = []
147
+
148
+ def update_sections_output():
149
+ return [section[0] for section in section_textboxes], [section[1] for section in section_textboxes]
150
+
151
+ add_section_btn.click(update_sections_output)
152
+
153
+ remove_section_btn.click(update_sections_output)
154
 
155
  generate_audio_btn = gr.Button("Générer l'audio")
156
 
157
+ def generate_all_sections(proj_folder):
158
  audio_outputs = []
159
+ for text_box, name_box in section_textboxes:
160
  text = text_box.value
161
  name = name_box.value
162
  audio_path = generate_audio_section(text, name.strip(), proj_folder.value, speaker.value)
 
167
 
168
  generate_audio_btn.click(
169
  generate_all_sections,
170
+ inputs=[project_folder_output],
171
  outputs=audio_outputs_display
172
  )
173