From 82725cea9c339cdc3a2004a622bba766b1871945 Mon Sep 17 00:00:00 2001 From: David Marx Date: Sun, 9 Oct 2022 02:14:03 -0700 Subject: [PATCH] infer download_root from XDG_CACHE_HOME if avail (#257) --- whisper/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/whisper/__init__.py b/whisper/__init__.py index dd2629a..9fbcc79 100644 --- a/whisper/__init__.py +++ b/whisper/__init__.py @@ -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)