Commit
·
beee88e
1
Parent(s):
418f3eb
Update app.py
Browse files
app.py
CHANGED
@@ -1,36 +1,17 @@
|
|
1 |
import gradio as gr
|
2 |
-
|
3 |
-
|
4 |
-
def
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
valore = lunghezza_audio_minuti * 100
|
18 |
-
|
19 |
-
return f"Valore calcolato: {valore:.2f}"
|
20 |
-
|
21 |
-
except Exception as e:
|
22 |
-
return f"Errore durante l'elaborazione del file audio: {str(e)}"
|
23 |
-
|
24 |
-
# Creare un'interfaccia Gradio
|
25 |
-
iface = gr.Interface(
|
26 |
-
fn=calcola_valore_da_audio,
|
27 |
-
inputs="audio",
|
28 |
-
outputs="text",
|
29 |
-
live=True,
|
30 |
-
title="Calcolatore Valore da Audio",
|
31 |
-
description="Inserisci un file audio e otterrai un valore in base alla sua lunghezza.",
|
32 |
-
allow_flagging=False
|
33 |
-
)
|
34 |
-
|
35 |
-
# Avvia l'interfaccia Gradio
|
36 |
iface.launch()
|
|
|
1 |
import gradio as gr
|
2 |
+
import librosa
|
3 |
+
|
4 |
+
def calculate_epochs(audio_file):
|
5 |
+
# Carica il file audio
|
6 |
+
y, sr = librosa.load(audio_file, sr=None)
|
7 |
+
|
8 |
+
# Calcola la durata in minuti
|
9 |
+
duration = librosa.get_duration(y, sr) / 60
|
10 |
+
|
11 |
+
# Calcola il numero di epoche
|
12 |
+
epochs = int(duration * 100)
|
13 |
+
|
14 |
+
return epochs
|
15 |
+
|
16 |
+
iface = gr.Interface(fn=calculate_epochs, inputs="file", outputs="text")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
iface.launch()
|