Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 27 additions & 9 deletions meet/transcribe.py
Original file line number Diff line number Diff line change
Expand Up @@ -494,23 +494,31 @@ def __post_init__(self):
# Validate device availability when torch is installed. We deliberately
# skip validation when torch can't be imported so that
# `TranscriptionConfig` remains constructible in torch-less test
# environments and lightweight CLI helpers (e.g. `meet check`).
# environments and lightweight CLI helpers.
#
# When the requested device is not available we automatically fall back
# to CPU instead of raising — this handles the common case where CUDA
# was requested but no GPU is present (e.g. running on a laptop or
# inside a container without GPU passthrough).
for field_name, value in (
("device", self.device),
("torch_device", self.torch_device),
):
available = _torch_device_available(value)
if available is None:
# torch is not installed (or device string is unknown to our
# helper) — skip.
continue
if not available:
raise ValueError(
f"{field_name}='{value}' but {value.upper()} is not "
f"available on this system. "
"Try --device cpu (and --torch-device cpu/mps) or install "
"the appropriate torch build."
fallback = "cpu" if value == "cuda" else "cpu"
log.warning(
"%s='%s' is not available, falling back to '%s'",
field_name, value, fallback,
)
if field_name == "device":
self.device = fallback
if self.compute_type == "float16":
self.compute_type = "int8"
elif field_name == "torch_device":
self.torch_device = fallback

if self.hf_token is None:
self.hf_token = os.environ.get("HF_TOKEN")
Expand Down Expand Up @@ -822,8 +830,18 @@ def _load_whisperx_asr_model(config: TranscriptionConfig, language: str | None):
"vad_onset": config.vad_onset,
"vad_offset": config.vad_offset,
}
device_note = ""
if config.device == "cpu":
try:
import torch as _torch
if _torch.cuda.is_available():
device_note = " (forced)"
else:
device_note = " (fallback — no GPU)"
except ImportError:
device_note = " (no torch)"
print(
f" Loading model: {config.model} ({config.compute_type}) on {config.device}"
f" Loading model: {config.model} ({config.compute_type}) on {config.device}{device_note}"
)
return whisperx.load_model(
config.model,
Expand Down