Skip to content

Commit

Permalink
Handle XDG_CACHE_HOME properly for download_root (openai#864)
Browse files Browse the repository at this point in the history
Co-authored-by: Jong Wook Kim <[email protected]>
  • Loading branch information
2 people authored and ilanit1997 committed May 16, 2023
1 parent 91d56d2 commit 2990115
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions whisper/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 2990115

Please sign in to comment.