|
import gradio as gr |
|
from pydub import AudioSegment |
|
|
|
def calcola_valore_da_audio(file_audio): |
|
|
|
file_audio_path = file_audio[0] if isinstance(file_audio, tuple) else file_audio |
|
|
|
try: |
|
|
|
audio = AudioSegment.from_file(file_audio_path) |
|
|
|
|
|
lunghezza_audio_minuti = len(audio) / (1000 * 60) |
|
|
|
|
|
valore = lunghezza_audio_minuti * 100 |
|
|
|
return f"Valore calcolato: {valore:.2f}" |
|
|
|
except Exception as e: |
|
return f"Errore durante l'elaborazione del file audio: {str(e)}" |
|
|
|
|
|
iface = gr.Interface( |
|
fn=calcola_valore_da_audio, |
|
inputs="audio", |
|
outputs="text", |
|
live=True, |
|
title="Ilaria Epochs Counter... idk the title man...", |
|
description="Inserisci un file audio e otterrai un valore in base alla sua lunghezza.", |
|
allow_flagging=False |
|
) |
|
|
|
|
|
iface.launch() |
|
|