From 38b9af7a86fe5bbfaf1c324e33fae6c03dfdc895 Mon Sep 17 00:00:00 2001 From: zer0-x Date: Thu, 19 Jan 2023 22:35:14 +0300 Subject: [PATCH] Handle XDG_CACHE_HOME properly for download_root --- whisper/__init__.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/whisper/__init__.py b/whisper/__init__.py index 2a1fb4ec..cb334065 100644 --- a/whisper/__init__.py +++ b/whisper/__init__.py @@ -94,9 +94,14 @@ 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.getenv( - "XDG_CACHE_HOME", - os.path.join(os.path.expanduser("~"), ".cache", "whisper") + download_root = os.path.join( + os.getenv( + "XDG_CACHE_HOME", + os.path.join( + os.path.expanduser("~"), ".cache" + ) + ), + "whisper" ) if name in _MODELS: