Spaces:
Sleeping
Sleeping
Download modules/utils/env.py from ProbablyBlue/ChatTTS-Forge: direct link, hf CLI and curl.
- Browser
- Download file 813 Bytes
-
https://huggingface.co/spaces/ProbablyBlue/ChatTTS-Forge/resolve/main/modules/utils/env.py
- Command line
-
hf download hf://spaces/ProbablyBlue/ChatTTS-Forge/modules/utils/env.py
-
curl -L -o env.py https://huggingface.co/spaces/ProbablyBlue/ChatTTS-Forge/resolve/main/modules/utils/env.py
813 Bytes
| import os | |
| from modules import config | |
| def get_env_val(key, val_type): | |
| env_val = os.getenv(key.upper()) | |
| if env_val is not None and env_val != "": | |
| if val_type == bool: | |
| return env_val.lower() in ("true", "1", "t") | |
| return val_type(env_val) | |
| if env_val == "": | |
| return None | |
| return env_val | |
| def get_env_or_arg(args, arg_name, default, arg_type): | |
| arg_val = getattr(args, arg_name) | |
| env_val = get_env_val(arg_name, arg_type) | |
| if arg_type == bool and env_val is not None: | |
| return env_val | |
| if arg_val is not None: | |
| return arg_val | |
| elif env_val is not None: | |
| return env_val | |
| return default | |
| def get_and_update_env(*args): | |
| val = get_env_or_arg(*args) | |
| key = args[1] | |
| config.runtime_env_vars[key] = val | |
| return val | |