Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -5,7 +5,6 @@ import torch
|
|
| 5 |
|
| 6 |
# --- Configuración Global ---
|
| 7 |
# Usamos 'tiny' para velocidad en CPU gratis.
|
| 8 |
-
# Cambiar a 'base' si tienes GPU pagada o más paciencia.
|
| 9 |
MODEL_NAME = "tiny"
|
| 10 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 11 |
|
|
@@ -30,7 +29,7 @@ def analizar_audio_evp(audio_path):
|
|
| 30 |
try:
|
| 31 |
# Opciones de transcripción agresivas para EVP
|
| 32 |
# temperature=0.8 ayuda a encontrar patrones en ruido (menos determinista)
|
| 33 |
-
# condition_on_previous_text=False evita que el modelo se 'bloquee'
|
| 34 |
options = {
|
| 35 |
"language": "es",
|
| 36 |
"fp16": False if device == "cpu" else True, # FP16 suele fallar en CPU
|
|
@@ -44,7 +43,8 @@ def analizar_audio_evp(audio_path):
|
|
| 44 |
texto = result["text"].strip()
|
| 45 |
|
| 46 |
if texto:
|
| 47 |
-
|
|
|
|
| 48 |
else:
|
| 49 |
return "💤 **SIN PATRONES:**\n\nEl IA no encontró estructuras lingüísticas claras en este ruido (o el silencio es absoluto)."
|
| 50 |
|
|
@@ -63,9 +63,9 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue="purple")) as demo:
|
|
| 63 |
with gr.Column():
|
| 64 |
audio_input = gr.Audio(
|
| 65 |
label="🎙️ Fuente de Audio",
|
| 66 |
-
type="filepath",
|
| 67 |
sources=["upload", "microphone"],
|
| 68 |
-
format="mp3"
|
| 69 |
)
|
| 70 |
btn_analizar = gr.Button("🔮 Analizar Ruido", variant="primary")
|
| 71 |
|
|
@@ -76,7 +76,6 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue="purple")) as demo:
|
|
| 76 |
max_lines=10
|
| 77 |
)
|
| 78 |
|
| 79 |
-
# Conectar botón a función
|
| 80 |
btn_analizar.click(
|
| 81 |
fn=analizar_audio_evp,
|
| 82 |
inputs=audio_input,
|
|
|
|
| 5 |
|
| 6 |
# --- Configuración Global ---
|
| 7 |
# Usamos 'tiny' para velocidad en CPU gratis.
|
|
|
|
| 8 |
MODEL_NAME = "tiny"
|
| 9 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 10 |
|
|
|
|
| 29 |
try:
|
| 30 |
# Opciones de transcripción agresivas para EVP
|
| 31 |
# temperature=0.8 ayuda a encontrar patrones en ruido (menos determinista)
|
| 32 |
+
# condition_on_previous_text=False evita que el modelo se 'bloquee'
|
| 33 |
options = {
|
| 34 |
"language": "es",
|
| 35 |
"fp16": False if device == "cpu" else True, # FP16 suele fallar en CPU
|
|
|
|
| 43 |
texto = result["text"].strip()
|
| 44 |
|
| 45 |
if texto:
|
| 46 |
+
# CORRECCIÓN AQUÍ: f-string bien cerrado
|
| 47 |
+
return f"👻 **PATRÓN DETECTADO:**\n\n{texto}"
|
| 48 |
else:
|
| 49 |
return "💤 **SIN PATRONES:**\n\nEl IA no encontró estructuras lingüísticas claras en este ruido (o el silencio es absoluto)."
|
| 50 |
|
|
|
|
| 63 |
with gr.Column():
|
| 64 |
audio_input = gr.Audio(
|
| 65 |
label="🎙️ Fuente de Audio",
|
| 66 |
+
type="filepath",
|
| 67 |
sources=["upload", "microphone"],
|
| 68 |
+
format="mp3"
|
| 69 |
)
|
| 70 |
btn_analizar = gr.Button("🔮 Analizar Ruido", variant="primary")
|
| 71 |
|
|
|
|
| 76 |
max_lines=10
|
| 77 |
)
|
| 78 |
|
|
|
|
| 79 |
btn_analizar.click(
|
| 80 |
fn=analizar_audio_evp,
|
| 81 |
inputs=audio_input,
|