Spaces:
Sleeping
Sleeping
Commit ยท
2d68666
1
Parent(s): 6449907
Aggiornamento a Canned Demo (risultati pre-calcolati)
Browse files- app.py +52 -38
- requirements.txt +0 -1
- risultati_demo/complete_test_results.json +0 -0
app.py
CHANGED
|
@@ -1,50 +1,64 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
import
|
| 3 |
-
import os
|
| 4 |
|
| 5 |
-
#
|
| 6 |
-
|
| 7 |
-
# -------------------------------------------
|
| 8 |
|
| 9 |
-
def
|
| 10 |
-
|
| 11 |
-
|
|
|
|
|
|
|
| 12 |
try:
|
| 13 |
-
with open(
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
except Exception as e:
|
| 36 |
-
|
| 37 |
|
|
|
|
| 38 |
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
| 39 |
-
gr.Markdown("# ๐ต Demo: Batch Audio Processor
|
| 40 |
-
gr.Markdown("
|
| 41 |
-
|
| 42 |
-
process_button = gr.Button("
|
|
|
|
| 43 |
with gr.Tabs():
|
| 44 |
-
with gr.TabItem("
|
| 45 |
report_output = gr.Markdown()
|
| 46 |
with gr.TabItem("๐ Dati JSON Completi"):
|
| 47 |
-
json_output = gr.JSON(label="
|
| 48 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
|
| 50 |
demo.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
import json
|
|
|
|
| 3 |
|
| 4 |
+
# Percorso al nostro file di risultati pre-calcolati
|
| 5 |
+
RISULTATI_PATH = "risultati_demo/complete_test_results.json"
|
|
|
|
| 6 |
|
| 7 |
+
def mostra_risultati_pronti():
|
| 8 |
+
"""
|
| 9 |
+
Questa funzione non esegue nessuna analisi.
|
| 10 |
+
Carica semplicemente i risultati dal file JSON locale e li formatta.
|
| 11 |
+
"""
|
| 12 |
try:
|
| 13 |
+
with open(RISULTATI_PATH, 'r') as f:
|
| 14 |
+
data = json.load(f)
|
| 15 |
+
|
| 16 |
+
# Formatta un report leggibile dai dati JSON
|
| 17 |
+
score = data.get('overall_score', 0)
|
| 18 |
+
integrazione = "โ
PASS" if data.get('integration', False) else "โ FAIL"
|
| 19 |
+
|
| 20 |
+
formatted_report = f"""
|
| 21 |
+
## ๐ Report Analisi Batch (Esempio Pre-Calcolato)
|
| 22 |
+
|
| 23 |
+
| Metrica | Risultato |
|
| 24 |
+
|---|---|
|
| 25 |
+
| **Score Complessivo** | **{score:.0f}%** |
|
| 26 |
+
| **Test di Integrazione** | {integrazione} |
|
| 27 |
+
| **File Audio Analizzati** | {len(data.get('performance', {}).get('file_details', []))} |
|
| 28 |
+
|
| 29 |
+
### Dettaglio Moduli Processori:
|
| 30 |
+
"""
|
| 31 |
+
for name, result in data.get('processors', {}).items():
|
| 32 |
+
status = result.get('status', 'N/D')
|
| 33 |
+
formatted_report += f"- **{name}**: {status}\n"
|
| 34 |
+
|
| 35 |
+
formatted_report += "\n*Questo รจ un esempio dei risultati generati dal sistema. L'analisi non รจ eseguita in tempo reale.*"
|
| 36 |
+
|
| 37 |
+
return formatted_report, data
|
| 38 |
+
|
| 39 |
+
except FileNotFoundError:
|
| 40 |
+
error_msg = "Errore: File dei risultati non trovato. Assicurati che 'risultati_demo/complete_test_results.json' sia stato caricato."
|
| 41 |
+
return error_msg, None
|
| 42 |
except Exception as e:
|
| 43 |
+
return f"Si รจ verificato un errore nel caricare i risultati: {e}", None
|
| 44 |
|
| 45 |
+
# --- Interfaccia Gradio ---
|
| 46 |
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
| 47 |
+
gr.Markdown("# ๐ต Demo 'Pronta': Batch Audio Processor")
|
| 48 |
+
gr.Markdown("Questa demo mostra i risultati di un'analisi batch giร eseguita. Clicca il pulsante per caricare e visualizzare il report completo.")
|
| 49 |
+
|
| 50 |
+
process_button = gr.Button("๐ Mostra Report di Esempio", variant="primary")
|
| 51 |
+
|
| 52 |
with gr.Tabs():
|
| 53 |
+
with gr.TabItem("๐ Report Riassuntivo"):
|
| 54 |
report_output = gr.Markdown()
|
| 55 |
with gr.TabItem("๐ Dati JSON Completi"):
|
| 56 |
+
json_output = gr.JSON(label="File di risultati completo")
|
| 57 |
+
|
| 58 |
+
process_button.click(
|
| 59 |
+
fn=mostra_risultati_pronti,
|
| 60 |
+
inputs=None, # Nessun input richiesto!
|
| 61 |
+
outputs=[report_output, json_output]
|
| 62 |
+
)
|
| 63 |
|
| 64 |
demo.launch()
|
requirements.txt
CHANGED
|
@@ -1,2 +1 @@
|
|
| 1 |
gradio
|
| 2 |
-
requests
|
|
|
|
| 1 |
gradio
|
|
|
risultati_demo/complete_test_results.json
ADDED
|
File without changes
|