Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -9,6 +9,12 @@ import os
|
|
9 |
|
10 |
def generate_waveform_video(audio_file, image_file):
|
11 |
try:
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
# 1. Cargar audio
|
13 |
y, sr = librosa.load(audio_file)
|
14 |
duration = librosa.get_duration(y=y, sr=sr)
|
@@ -40,7 +46,7 @@ def generate_waveform_video(audio_file, image_file):
|
|
40 |
buf = io.BytesIO()
|
41 |
plt.savefig(buf, format='png', bbox_inches='tight', pad_inches=0)
|
42 |
plt.close(fig)
|
43 |
-
return np.array(Image.open(buf))
|
44 |
|
45 |
# Crear video
|
46 |
effect_clip = mp.VideoClip(make_frame, duration=duration).set_fps(24)
|
@@ -54,7 +60,8 @@ def generate_waveform_video(audio_file, image_file):
|
|
54 |
return tmpfile.name
|
55 |
|
56 |
except Exception as e:
|
57 |
-
|
|
|
58 |
|
59 |
# Interfaz Gradio
|
60 |
iface = gr.Interface(
|
|
|
9 |
|
10 |
def generate_waveform_video(audio_file, image_file):
|
11 |
try:
|
12 |
+
# Validar que los archivos existan
|
13 |
+
if not os.path.exists(audio_file):
|
14 |
+
raise ValueError("Archivo de audio no encontrado")
|
15 |
+
if not os.path.exists(image_file):
|
16 |
+
raise ValueError("Archivo de imagen no encontrado")
|
17 |
+
|
18 |
# 1. Cargar audio
|
19 |
y, sr = librosa.load(audio_file)
|
20 |
duration = librosa.get_duration(y=y, sr=sr)
|
|
|
46 |
buf = io.BytesIO()
|
47 |
plt.savefig(buf, format='png', bbox_inches='tight', pad_inches=0)
|
48 |
plt.close(fig)
|
49 |
+
return np.array(Image.open(buf))
|
50 |
|
51 |
# Crear video
|
52 |
effect_clip = mp.VideoClip(make_frame, duration=duration).set_fps(24)
|
|
|
60 |
return tmpfile.name
|
61 |
|
62 |
except Exception as e:
|
63 |
+
# Lanzar excepci贸n para que Gradio muestre el error
|
64 |
+
raise Exception(f"Error durante la generaci贸n: {str(e)}")
|
65 |
|
66 |
# Interfaz Gradio
|
67 |
iface = gr.Interface(
|