Spaces:
Running
on
Zero
Running
on
Zero
Update gradio_mix.py
Browse files- gradio_mix.py +6 -8
gradio_mix.py
CHANGED
|
@@ -426,14 +426,15 @@ class MMSAlignModel:
|
|
| 426 |
|
| 427 |
class WhisperxModel:
|
| 428 |
def __init__(self, model_name):
|
| 429 |
-
# Lazily construct the WhisperX pipeline
|
| 430 |
-
# touch CUDA inside spaces.GPU workers.
|
| 431 |
self.model_name = model_name
|
| 432 |
self.model = None
|
| 433 |
-
|
| 434 |
-
|
| 435 |
-
|
| 436 |
self.device = "cpu"
|
|
|
|
|
|
|
| 437 |
|
| 438 |
def _ensure_model(self):
|
| 439 |
if self.model is not None:
|
|
@@ -673,9 +674,6 @@ def get_transcribe_state(segments):
|
|
| 673 |
"word_bounds": [f"{word['start']} {word['word']} {word['end']}" for word in segments["words"]]
|
| 674 |
}
|
| 675 |
|
| 676 |
-
@spaces.GPU
|
| 677 |
-
@torch.no_grad()
|
| 678 |
-
@torch.inference_mode()
|
| 679 |
def transcribe(seed, audio_info):
|
| 680 |
if transcribe_model is None:
|
| 681 |
raise gr.Error("Transcription model not loaded")
|
|
|
|
| 426 |
|
| 427 |
class WhisperxModel:
|
| 428 |
def __init__(self, model_name):
|
| 429 |
+
# Lazily construct the WhisperX pipeline.
|
|
|
|
| 430 |
self.model_name = model_name
|
| 431 |
self.model = None
|
| 432 |
+
# In HF Spaces ZeroGPU, CUDA/cuDNN may not be fully available for
|
| 433 |
+
# WhisperX, so we force CPU there. Locally, prefer CUDA if available.
|
| 434 |
+
if IS_SPACES:
|
| 435 |
self.device = "cpu"
|
| 436 |
+
else:
|
| 437 |
+
self.device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 438 |
|
| 439 |
def _ensure_model(self):
|
| 440 |
if self.model is not None:
|
|
|
|
| 674 |
"word_bounds": [f"{word['start']} {word['word']} {word['end']}" for word in segments["words"]]
|
| 675 |
}
|
| 676 |
|
|
|
|
|
|
|
|
|
|
| 677 |
def transcribe(seed, audio_info):
|
| 678 |
if transcribe_model is None:
|
| 679 |
raise gr.Error("Transcription model not loaded")
|