Spaces:
Sleeping
Sleeping
""" | |
Configuration for Kokoro TTS API, especially for Hugging Face Spaces deployment. | |
""" | |
import os | |
import tempfile | |
import logging | |
# Configure logging | |
logging.basicConfig(level=logging.INFO) | |
logger = logging.getLogger(__name__) | |
def setup_hf_cache(): | |
"""Setup cache environment variables for Hugging Face Spaces""" | |
# Don't try to create custom directories, just set environment variables | |
# HF Spaces will handle the actual cache locations | |
cache_settings = { | |
'NUMBA_DISABLE_JIT': '1', | |
'HF_HUB_DISABLE_TELEMETRY': '1' | |
} | |
# Set environment variables | |
for key, value in cache_settings.items(): | |
os.environ[key] = value | |
logger.info(f"Set {key} to {value}") | |
logger.info("Cache environment setup completed") | |
def get_temp_dir(): | |
"""Get a writable temporary directory""" | |
return tempfile.gettempdir() | |
def is_hf_spaces(): | |
"""Check if running on Hugging Face Spaces""" | |
return os.environ.get('SPACE_ID') is not None | |
# Initialize cache setup | |
setup_hf_cache() |