Skip to content

Commit

Permalink
infer download_root from XDG_CACHE_HOME if avail (openai#257)
Browse files Browse the repository at this point in the history
  • Loading branch information
dmarx committed Oct 9, 2022
1 parent 35713c6 commit 82725ce
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion whisper/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,10 @@ def load_model(name: str, device: Optional[Union[str, torch.device]] = None, dow
if device is None:
device = "cuda" if torch.cuda.is_available() else "cpu"
if download_root is None:
download_root = os.path.join(os.path.expanduser("~"), ".cache", "whisper")
download_root = os.getenv(
"XDG_CACHE_HOME",
os.path.join(os.path.expanduser("~"), ".cache", "whisper")
)

if name in _MODELS:
checkpoint_file = _download(_MODELS[name], download_root, in_memory)
Expand Down

0 comments on commit 82725ce

Please sign in to comment.