Update app.py
Browse files
app.py
CHANGED
|
@@ -6,14 +6,16 @@ from typing import Dict, Any, List, Tuple, Optional
|
|
| 6 |
import gradio as gr
|
| 7 |
import spaces
|
| 8 |
|
| 9 |
-
# faster-whisper (CTranslate2)
|
| 10 |
-
from faster_whisper import WhisperModel
|
| 11 |
-
|
| 12 |
from torch.serialization import add_safe_globals
|
| 13 |
from torch.torch_version import TorchVersion
|
| 14 |
|
| 15 |
add_safe_globals([TorchVersion])
|
| 16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
# =========================
|
| 18 |
# Config y carga perezosa
|
| 19 |
# =========================
|
|
@@ -29,6 +31,7 @@ COMPUTE_TYPE = "float16" if HAS_CUDA else "int8" # "int8_float16" también vale
|
|
| 29 |
_model: Optional[WhisperModel] = None
|
| 30 |
|
| 31 |
def _lazy_model() -> WhisperModel:
|
|
|
|
| 32 |
if _model is None:
|
| 33 |
_model = WhisperModel(
|
| 34 |
MODEL_ID,
|
|
@@ -46,6 +49,7 @@ def _lazy_load_whisper():
|
|
| 46 |
Lazy load para Whisper en HuggingFace Spaces (Stateless GPU compatible).
|
| 47 |
Evita inicializar CUDA en el proceso principal.
|
| 48 |
"""
|
|
|
|
| 49 |
if _model_whis is None or _processor_whis is None:
|
| 50 |
model_name = "projecte-aina/whisper-large-v3-ca-3catparla"
|
| 51 |
|
|
|
|
| 6 |
import gradio as gr
|
| 7 |
import spaces
|
| 8 |
|
|
|
|
|
|
|
|
|
|
| 9 |
from torch.serialization import add_safe_globals
|
| 10 |
from torch.torch_version import TorchVersion
|
| 11 |
|
| 12 |
add_safe_globals([TorchVersion])
|
| 13 |
|
| 14 |
+
# faster-whisper (CTranslate2)
|
| 15 |
+
from faster_whisper import WhisperModel
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
|
| 19 |
# =========================
|
| 20 |
# Config y carga perezosa
|
| 21 |
# =========================
|
|
|
|
| 31 |
_model: Optional[WhisperModel] = None
|
| 32 |
|
| 33 |
def _lazy_model() -> WhisperModel:
|
| 34 |
+
global _model
|
| 35 |
if _model is None:
|
| 36 |
_model = WhisperModel(
|
| 37 |
MODEL_ID,
|
|
|
|
| 49 |
Lazy load para Whisper en HuggingFace Spaces (Stateless GPU compatible).
|
| 50 |
Evita inicializar CUDA en el proceso principal.
|
| 51 |
"""
|
| 52 |
+
global _model_whis, _processor_whis
|
| 53 |
if _model_whis is None or _processor_whis is None:
|
| 54 |
model_name = "projecte-aina/whisper-large-v3-ca-3catparla"
|
| 55 |
|