Skip to content

SUPERTONIC_CACHE_DIR ignored when model name is passed (the default code path) #117

@dominvo

Description

@dominvo

Summary

SUPERTONIC_CACHE_DIR is documented as the way to override the model cache location, but it is silently ignored on the most common code path — when TTS() is constructed with a model name (which is the default behaviour, since model: str = 'supertonic-3' in the TTS.__init__ signature).

Reproduction (supertonic 1.2.3)

export SUPERTONIC_CACHE_DIR=/tmp/custom-cache
python3 -c "
from supertonic import TTS
tts = TTS(auto_download=True)
print('model_dir:', tts.model_dir)
"

Expected: model_dir: /tmp/custom-cache
Actual: model_dir: /Users/<user>/.cache/supertonic3

The env var is fully honored only if model_name=None is passed explicitly, which contradicts both the docstring of get_cache_dir() and the comment in config.py:24 that suggests the env var is the user-facing override.

Root cause

supertonic/loader.py:58-60:

if model_name is not None:
    cache_dir = get_model_cache_dir(model_name)   # ← hardcoded ~/.cache/{name}
else:
    cache_dir = Path(DEFAULT_CACHE_DIR)            # ← env-var aware

get_model_cache_dir() in config.py:77-87 is hardcoded to Path.home() / ".cache" / config["cache_dir"] regardless of SUPERTONIC_CACHE_DIR.

Suggested fix

One-liner — make get_model_cache_dir honor the env var, e.g.:

def get_model_cache_dir(model_name: str) -> Path:
    config = get_model_config(model_name)
    base = os.environ.get("SUPERTONIC_CACHE_DIR")
    if base:
        return Path(base)
    return Path.home() / ".cache" / config["cache_dir"]

(Or, equivalently, make get_cache_dir() consult DEFAULT_CACHE_DIR first and fall back to get_model_cache_dir() only when the env var is unset.)

Workaround for now

Pass model_dir explicitly:

import os
from supertonic import TTS
tts = TTS(auto_download=True, model_dir=os.environ.get("SUPERTONIC_CACHE_DIR"))

Not a blocker — just a friction point for anyone redirecting caches to a non-default volume (external SSDs, network mounts, container volumes). Thanks for the great library!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions