Merlintxu commited on
Commit
3b3b78f
verified
1 Parent(s): 9f91ed0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -7
app.py CHANGED
@@ -229,13 +229,25 @@ def transcribe_and_diarize(audio_file, num_speakers):
229
  print(f"Archivo temporal eliminado: {f}")
230
  except OSError:
231
  pass
232
- # Liberar memoria GPU/CPU
233
- if 'whisper_model' in globals():
234
- del whisper_model
235
- if 'embedding_model' in globals():
236
- del embedding_model
 
 
 
 
 
 
 
 
 
 
 
237
  gc.collect()
238
- torch.cuda.empty_cache() if torch.cuda.is_available() else None
 
239
 
240
  # --- Interfaz Gradio ---
241
  with gr.Blocks(title="Diarizaci贸n de Audio en Espa帽ol") as demo:
@@ -262,7 +274,7 @@ with gr.Blocks(title="Diarizaci贸n de Audio en Espa帽ol") as demo:
262
 
263
  gr.Markdown("---")
264
  gr.Markdown("**Modelos Usados:**\n"
265
- "* **Transcripci贸n:** Whisper (`small`)\n"
266
  "* **Diarizaci贸n:** Pyannote.Audio (`pyannote/embedding` o `speechbrain/spkrec-ecapa-voxceleb`)\n")
267
 
268
  # Para Hugging Face Spaces
 
229
  print(f"Archivo temporal eliminado: {f}")
230
  except OSError:
231
  pass
232
+ # Liberar memoria GPU/CPU (manera m谩s segura)
233
+ import sys
234
+ if 'whisper_model' in sys.modules.get(__name__, {}).__dict__:
235
+ try:
236
+ del sys.modules[__name__].whisper_model
237
+ print("Modelo Whisper eliminado de la memoria.")
238
+ except Exception as e:
239
+ print(f"Error al eliminar whisper_model: {e}")
240
+
241
+ if 'embedding_model' in sys.modules.get(__name__, {}).__dict__:
242
+ try:
243
+ del sys.modules[__name__].embedding_model
244
+ print("Modelo de embeddings eliminado de la memoria.")
245
+ except Exception as e:
246
+ print(f"Error al eliminar embedding_model: {e}")
247
+
248
  gc.collect()
249
+ if torch.cuda.is_available():
250
+ torch.cuda.empty_cache()
251
 
252
  # --- Interfaz Gradio ---
253
  with gr.Blocks(title="Diarizaci贸n de Audio en Espa帽ol") as demo:
 
274
 
275
  gr.Markdown("---")
276
  gr.Markdown("**Modelos Usados:**\n"
277
+ "* **Transcripci贸n:** Whisper (`large-v3`)\n"
278
  "* **Diarizaci贸n:** Pyannote.Audio (`pyannote/embedding` o `speechbrain/spkrec-ecapa-voxceleb`)\n")
279
 
280
  # Para Hugging Face Spaces