42 lines
1.7 KiB
Python
42 lines
1.7 KiB
Python
import os
|
|
from pathlib import Path
|
|
from dotenv import load_dotenv
|
|
|
|
# Load environment variables from .env file
|
|
load_dotenv()
|
|
|
|
# Project root - can be overridden by environment variable
|
|
PROJECT_ROOT = Path(os.getenv("PROJECT_ROOT", Path(__file__).parent.parent.parent)).resolve()
|
|
|
|
# Directory paths
|
|
SPEAKER_DATA_BASE_DIR = Path(os.getenv("SPEAKER_DATA_BASE_DIR", str(PROJECT_ROOT / "speaker_data")))
|
|
SPEAKER_SAMPLES_DIR = Path(os.getenv("SPEAKER_SAMPLES_DIR", str(SPEAKER_DATA_BASE_DIR / "speaker_samples")))
|
|
SPEAKERS_YAML_FILE = Path(os.getenv("SPEAKERS_YAML_FILE", str(SPEAKER_DATA_BASE_DIR / "speakers.yaml")))
|
|
|
|
# TTS temporary output path (used by DialogProcessorService)
|
|
TTS_TEMP_OUTPUT_DIR = Path(os.getenv("TTS_TEMP_OUTPUT_DIR", str(PROJECT_ROOT / "tts_temp_outputs")))
|
|
|
|
# Final dialog output path (used by Dialog router and served by main app)
|
|
# These are stored within the 'backend' directory to be easily servable.
|
|
DIALOG_OUTPUT_PARENT_DIR = PROJECT_ROOT / "backend"
|
|
DIALOG_GENERATED_DIR = Path(os.getenv("DIALOG_GENERATED_DIR", str(DIALOG_OUTPUT_PARENT_DIR / "tts_generated_dialogs")))
|
|
|
|
# Alias for clarity and backward compatibility
|
|
DIALOG_OUTPUT_DIR = DIALOG_GENERATED_DIR
|
|
|
|
# Server configuration
|
|
HOST = os.getenv("HOST", "0.0.0.0")
|
|
PORT = int(os.getenv("PORT", "8000"))
|
|
RELOAD = os.getenv("RELOAD", "true").lower() == "true"
|
|
|
|
# CORS configuration
|
|
CORS_ORIGINS = [origin.strip() for origin in os.getenv("CORS_ORIGINS", "http://localhost:8001,http://127.0.0.1:8001").split(",")]
|
|
|
|
# Device configuration
|
|
DEVICE = os.getenv("DEVICE", "auto")
|
|
|
|
# Ensure directories exist
|
|
SPEAKER_SAMPLES_DIR.mkdir(parents=True, exist_ok=True)
|
|
TTS_TEMP_OUTPUT_DIR.mkdir(parents=True, exist_ok=True)
|
|
DIALOG_GENERATED_DIR.mkdir(parents=True, exist_ok=True)
|