Spaces:
Sleeping
Sleeping
Download app.py from antoniiiii/batch-processor: direct link, hf CLI and curl.
- Browser
- Download file 2.48 kB
-
https://huggingface.co/spaces/antoniiiii/batch-processor/resolve/main/app.py
- Command line
-
hf download hf://spaces/antoniiiii/batch-processor/app.py
-
curl -L -o app.py https://huggingface.co/spaces/antoniiiii/batch-processor/resolve/main/app.py
2.48 kB
| import gradio as gr | |
| import json | |
| # Percorso al nostro file di risultati pre-calcolati | |
| RISULTATI_PATH = "risultati_demo/complete_test_results.json" | |
| def mostra_risultati_pronti(): | |
| """ | |
| Questa funzione non esegue nessuna analisi. | |
| Carica semplicemente i risultati dal file JSON locale e li formatta. | |
| """ | |
| try: | |
| with open(RISULTATI_PATH, 'r') as f: | |
| data = json.load(f) | |
| # Formatta un report leggibile dai dati JSON | |
| score = data.get('overall_score', 0) | |
| integrazione = "β PASS" if data.get('integration', False) else "β FAIL" | |
| formatted_report = f""" | |
| ## π Report Analisi Batch (Esempio Pre-Calcolato) | |
| | Metrica | Risultato | | |
| |---|---| | |
| | **Score Complessivo** | **{score:.0f}%** | | |
| | **Test di Integrazione** | {integrazione} | | |
| | **File Audio Analizzati** | {len(data.get('performance', {}).get('file_details', []))} | | |
| ### Dettaglio Moduli Processori: | |
| """ | |
| for name, result in data.get('processors', {}).items(): | |
| status = result.get('status', 'N/D') | |
| formatted_report += f"- **{name}**: {status}\n" | |
| formatted_report += "\n*Questo Γ¨ un esempio dei risultati generati dal sistema. L'analisi non Γ¨ eseguita in tempo reale.*" | |
| return formatted_report, data | |
| except FileNotFoundError: | |
| error_msg = "Errore: File dei risultati non trovato. Assicurati che 'risultati_demo/complete_test_results.json' sia stato caricato." | |
| return error_msg, None | |
| except Exception as e: | |
| return f"Si Γ¨ verificato un errore nel caricare i risultati: {e}", None | |
| # --- Interfaccia Gradio --- | |
| with gr.Blocks(theme=gr.themes.Soft()) as demo: | |
| gr.Markdown("# π΅ Demo 'Pronta': Batch Audio Processor") | |
| gr.Markdown("Questa demo mostra i risultati di un'analisi batch giΓ eseguita. Clicca il pulsante per caricare e visualizzare il report completo.") | |
| process_button = gr.Button("π Mostra Report di Esempio", variant="primary") | |
| with gr.Tabs(): | |
| with gr.TabItem("π Report Riassuntivo"): | |
| report_output = gr.Markdown() | |
| with gr.TabItem("π Dati JSON Completi"): | |
| json_output = gr.JSON(label="File di risultati completo") | |
| process_button.click( | |
| fn=mostra_risultati_pronti, | |
| inputs=None, # Nessun input richiesto! | |
| outputs=[report_output, json_output] | |
| ) | |
| demo.launch() |