Files
audiobook-maker-pro-v4/config.py
Ashim Kumar 8e02b9ad09 first commit
2026-02-20 13:53:36 +06:00

68 lines
2.2 KiB
Python

# config.py - Application Configuration
import os
import uuid
from dotenv import load_dotenv
# Load environment variables
load_dotenv()
# --- DATABASE ---
# In production (Docker), the DATABASE env var points to the persistent volume.
# Locally it falls back to the current directory.
DATABASE = os.getenv('DATABASE', 'audiobook_maker.db')
# --- Ensure the database directory exists ---
_db_dir = os.path.dirname(DATABASE)
if _db_dir and not os.path.exists(_db_dir):
os.makedirs(_db_dir, exist_ok=True)
print(f"📁 Created database directory: {_db_dir}")
# --- FLASK SECRET KEY ---
SECRET_KEY = os.getenv('SECRET_KEY', 'audiobook-maker-pro-' + str(uuid.uuid4()))
# --- TTS API CONFIGURATION ---
TTS_API_URL = os.getenv('TTS_API_URL', 'http://localhost:5010/api/v1')
TTS_API_KEY = os.getenv('TTS_API_KEY', '')
# --- PATHS ---
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
STATIC_FOLDER = 'static'
STATIC_URL_PATH = '/static'
# --- API HEADERS ---
def get_api_headers():
"""Get headers for TTS API requests."""
return {
'X-API-Key': TTS_API_KEY
}
def get_api_headers_json():
"""Get headers for TTS API requests with JSON content type."""
return {
'X-API-Key': TTS_API_KEY,
'Content-Type': 'application/json'
}
# --- VOICE OPTIONS ---
VOICES = [
{'id': 'af_alloy', 'name': 'Alloy (US Female)'},
{'id': 'af_aoede', 'name': 'Aoede (US Female)'},
{'id': 'af_bella', 'name': 'Bella (US Female)'},
{'id': 'af_heart', 'name': 'Heart (US Female)'},
{'id': 'af_jessica', 'name': 'Jessica (US Female)'},
{'id': 'af_nicole', 'name': 'Nicole (US Female)'},
{'id': 'af_nova', 'name': 'Nova (US Female)'},
{'id': 'af_river', 'name': 'River (US Female)'},
{'id': 'af_sarah', 'name': 'Sarah (US Female)'},
{'id': 'af_sky', 'name': 'Sky (US Female)'},
{'id': 'am_adam', 'name': 'Adam (US Male)'},
{'id': 'am_echo', 'name': 'Echo (US Male)'},
{'id': 'am_eric', 'name': 'Eric (US Male)'},
{'id': 'am_michael', 'name': 'Michael (US Male)'},
{'id': 'bf_emma', 'name': 'Emma (UK Female)'},
{'id': 'bf_isabella', 'name': 'Isabella (UK Female)'},
{'id': 'bm_daniel', 'name': 'Daniel (UK Male)'},
{'id': 'bm_george', 'name': 'George (UK Male)'},
]