Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -251,32 +251,41 @@ def create_interface():
|
|
| 251 |
|
| 252 |
with gr.Row():
|
| 253 |
with gr.Column():
|
|
|
|
| 254 |
model_selector = gr.Dropdown(
|
| 255 |
choices=["model_1.pth", "model_2.pth", "model_3.pth"],
|
| 256 |
value="model_3.pth",
|
| 257 |
label="Choisissez le modèle"
|
| 258 |
)
|
| 259 |
|
|
|
|
| 260 |
with gr.Tab("Microphone"):
|
| 261 |
mic_input = gr.Audio(sources=["microphone"], type="filepath", label="🎙️ Enregistrer depuis le microphone")
|
| 262 |
|
| 263 |
with gr.Tab("Upload Audio"):
|
| 264 |
file_input = gr.Audio(sources=["upload"], type="filepath", label="📁 Télécharger un fichier audio")
|
| 265 |
|
|
|
|
| 266 |
record_btn = gr.Button("Reconnaître")
|
| 267 |
|
| 268 |
with gr.Column():
|
|
|
|
| 269 |
result_text = gr.Textbox(label="Résultat")
|
| 270 |
plot_output = gr.Plot(label="Confiance par locuteur")
|
| 271 |
recognized_text = gr.Textbox(label="Texte reconnu")
|
| 272 |
audio_output = gr.Audio(label="Synthèse vocale", visible=False)
|
| 273 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 274 |
record_btn.click(
|
| 275 |
fn=recognize,
|
| 276 |
-
inputs=[
|
| 277 |
outputs=[result_text, plot_output, recognized_text, audio_output]
|
| 278 |
)
|
| 279 |
-
|
| 280 |
return interface
|
| 281 |
|
| 282 |
if __name__ == "__main__":
|
|
|
|
| 251 |
|
| 252 |
with gr.Row():
|
| 253 |
with gr.Column():
|
| 254 |
+
# Dropdown pour sélectionner le modèle
|
| 255 |
model_selector = gr.Dropdown(
|
| 256 |
choices=["model_1.pth", "model_2.pth", "model_3.pth"],
|
| 257 |
value="model_3.pth",
|
| 258 |
label="Choisissez le modèle"
|
| 259 |
)
|
| 260 |
|
| 261 |
+
# Créer des onglets pour Microphone et Upload Audio
|
| 262 |
with gr.Tab("Microphone"):
|
| 263 |
mic_input = gr.Audio(sources=["microphone"], type="filepath", label="🎙️ Enregistrer depuis le microphone")
|
| 264 |
|
| 265 |
with gr.Tab("Upload Audio"):
|
| 266 |
file_input = gr.Audio(sources=["upload"], type="filepath", label="📁 Télécharger un fichier audio")
|
| 267 |
|
| 268 |
+
# Bouton pour démarrer la reconnaissance
|
| 269 |
record_btn = gr.Button("Reconnaître")
|
| 270 |
|
| 271 |
with gr.Column():
|
| 272 |
+
# Résultat, graphique et texte reconnu
|
| 273 |
result_text = gr.Textbox(label="Résultat")
|
| 274 |
plot_output = gr.Plot(label="Confiance par locuteur")
|
| 275 |
recognized_text = gr.Textbox(label="Texte reconnu")
|
| 276 |
audio_output = gr.Audio(label="Synthèse vocale", visible=False)
|
| 277 |
+
|
| 278 |
+
# Fonction de clique pour la reconnaissance
|
| 279 |
+
def recognize(audio, selected_model):
|
| 280 |
+
# Traitement audio et modèle à charger...
|
| 281 |
+
pass # Remplace ici avec ton code de traitement
|
| 282 |
+
|
| 283 |
+
# Lier le bouton "Reconnaître" à la fonction
|
| 284 |
record_btn.click(
|
| 285 |
fn=recognize,
|
| 286 |
+
inputs=[mic_input, file_input, model_selector], # Remplacer Union par les deux inputs distincts
|
| 287 |
outputs=[result_text, plot_output, recognized_text, audio_output]
|
| 288 |
)
|
|
|
|
| 289 |
return interface
|
| 290 |
|
| 291 |
if __name__ == "__main__":
|