Update pipeline/asr_diarization.py
Browse files
pipeline/asr_diarization.py
CHANGED
|
@@ -7,7 +7,6 @@ _metadata = None
|
|
| 7 |
def load_asr(device="cpu", model_size="medium"):
|
| 8 |
global _asr_model
|
| 9 |
if _asr_model is None:
|
| 10 |
-
# force float32 so it doesn’t try to use unsupported float16 on CPU / limited GPU
|
| 11 |
_asr_model = whisperx.load_model(model_size, device=device, compute_type="float32")
|
| 12 |
return _asr_model
|
| 13 |
|
|
@@ -20,7 +19,8 @@ def transcribe_and_align(audio_path: str, device="cpu"):
|
|
| 20 |
_alignment_model, _metadata = whisperx.load_align_model(
|
| 21 |
language_code=result["language"], device=device
|
| 22 |
)
|
|
|
|
| 23 |
result_aligned = whisperx.align(
|
| 24 |
-
result["segments"], _alignment_model, _metadata, audio_path
|
| 25 |
)
|
| 26 |
return result, result_aligned
|
|
|
|
| 7 |
def load_asr(device="cpu", model_size="medium"):
|
| 8 |
global _asr_model
|
| 9 |
if _asr_model is None:
|
|
|
|
| 10 |
_asr_model = whisperx.load_model(model_size, device=device, compute_type="float32")
|
| 11 |
return _asr_model
|
| 12 |
|
|
|
|
| 19 |
_alignment_model, _metadata = whisperx.load_align_model(
|
| 20 |
language_code=result["language"], device=device
|
| 21 |
)
|
| 22 |
+
# Pass device here as required
|
| 23 |
result_aligned = whisperx.align(
|
| 24 |
+
result["segments"], _alignment_model, _metadata, audio_path, device=device
|
| 25 |
)
|
| 26 |
return result, result_aligned
|