Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -38,17 +38,27 @@ def eliminar_archivo_tiempo(ruta, delay=1800):
|
|
38 |
logging.error(f"Error al eliminar {ruta}: {e}")
|
39 |
Timer(delay, eliminar).start()
|
40 |
|
|
|
41 |
def validar_texto(texto):
|
42 |
-
"""
|
43 |
texto_limpio = texto.strip()
|
44 |
if len(texto_limpio) < 3:
|
45 |
-
|
|
|
|
|
|
|
46 |
if any(c in texto_limpio for c in ["|", "\n", "\r"]):
|
47 |
-
|
48 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
|
50 |
async def procesar_audio(texto, voz, duracion_total, duracion_intro):
|
51 |
-
"""Genera TTS y mezcla con música
|
52 |
temp_files = []
|
53 |
try:
|
54 |
# Validaciones críticas
|
@@ -188,7 +198,8 @@ with gr.Blocks() as demo:
|
|
188 |
texto_tts = gr.Textbox(
|
189 |
label="Texto para TTS",
|
190 |
lines=3,
|
191 |
-
value="¡Hola! Esto es una prueba. Suscríbete al canal y activa la campanita."
|
|
|
192 |
)
|
193 |
voz_seleccionada = gr.Dropdown(
|
194 |
label="Voz",
|
@@ -213,7 +224,7 @@ with gr.Blocks() as demo:
|
|
213 |
procesar_video,
|
214 |
inputs=[
|
215 |
video_input,
|
216 |
-
texto_tts
|
217 |
voz_seleccionada,
|
218 |
metodo_corte,
|
219 |
duracion_corte
|
|
|
38 |
logging.error(f"Error al eliminar {ruta}: {e}")
|
39 |
Timer(delay, eliminar).start()
|
40 |
|
41 |
+
@gr.validation
|
42 |
def validar_texto(texto):
|
43 |
+
"""Validación de texto para TTS"""
|
44 |
texto_limpio = texto.strip()
|
45 |
if len(texto_limpio) < 3:
|
46 |
+
return gr.ValidationResult(
|
47 |
+
success=False,
|
48 |
+
message="⚠️ El texto debe tener al menos 3 caracteres"
|
49 |
+
)
|
50 |
if any(c in texto_limpio for c in ["|", "\n", "\r"]):
|
51 |
+
return gr.ValidationResult(
|
52 |
+
success=False,
|
53 |
+
message="⚠️ Caracteres no permitidos detectados"
|
54 |
+
)
|
55 |
+
return gr.ValidationResult(
|
56 |
+
success=True,
|
57 |
+
message="✅ Texto válido"
|
58 |
+
)
|
59 |
|
60 |
async def procesar_audio(texto, voz, duracion_total, duracion_intro):
|
61 |
+
"""Genera TTS y mezcla con música"""
|
62 |
temp_files = []
|
63 |
try:
|
64 |
# Validaciones críticas
|
|
|
198 |
texto_tts = gr.Textbox(
|
199 |
label="Texto para TTS",
|
200 |
lines=3,
|
201 |
+
value="¡Hola! Esto es una prueba. Suscríbete al canal y activa la campanita.",
|
202 |
+
validate=validar_texto # Validación activada
|
203 |
)
|
204 |
voz_seleccionada = gr.Dropdown(
|
205 |
label="Voz",
|
|
|
224 |
procesar_video,
|
225 |
inputs=[
|
226 |
video_input,
|
227 |
+
texto_tts,
|
228 |
voz_seleccionada,
|
229 |
metodo_corte,
|
230 |
duracion_corte
|