Refactor the TTS handling to support multiple, user-selectable voices. This replaces the previous single-voice system. Key changes: - Introduce VoiceManager to handle loading and managing voices from a dedicated oices/ directory. - Add slash commands (/voice list, /set, /current, /refresh) for users to manage their personal TTS voice. - Implement on-demand voice loading to improve startup time and memory usage. - Remove the old ts_handler.py and single voice .wav files in favor of the new system. - Update configuration to specify a voices directory instead of a single file path.
24 lines
780 B
Python
24 lines
780 B
Python
import os
|
|
from dotenv import load_dotenv
|
|
|
|
load_dotenv()
|
|
|
|
|
|
class Config:
|
|
DISCORD_TOKEN: str = os.getenv("DISCORD_TOKEN", "")
|
|
TEXT_CHANNEL_ID: int = int(os.getenv("TEXT_CHANNEL_ID", "0"))
|
|
VOICES_DIR: str = os.getenv("VOICES_DIR", "./voices")
|
|
DEFAULT_VOICE: str | None = os.getenv("DEFAULT_VOICE", None)
|
|
|
|
@classmethod
|
|
def validate(cls) -> list[str]:
|
|
"""Validate configuration and return list of errors."""
|
|
errors = []
|
|
if not cls.DISCORD_TOKEN:
|
|
errors.append("DISCORD_TOKEN is not set")
|
|
if cls.TEXT_CHANNEL_ID == 0:
|
|
errors.append("TEXT_CHANNEL_ID is not set")
|
|
if not os.path.exists(cls.VOICES_DIR):
|
|
errors.append(f"Voices directory not found: {cls.VOICES_DIR}")
|
|
return errors
|