{"repo": "aivrar/localsoundsapi", "files": {"config.py": {"2e9f4e27b714d7715a89f512e232f58ac74a2a80": {"t": 1785674380.881361, "n": 5426, "h": "5c22de48a740db2c", "c": "# config.py\nfrom pathlib import Path\nimport os\nimport torch\n\nAPP_ROOT = Path(__file__).parent.resolve()\n\nVOICE_DIR = APP_ROOT / \"voices\" # The app's directory for your referance voices\nOUTPUT_DIR = APP_ROOT / \"output_tts\" # The app's work directory, can get cluttered up watch out.\nDELETE_OUTPUT_ON_STARTUP = True # Empty the app's work directory on each start up, stays clean\n\n# The following bin items you may already have installed somewhere, you can connect directly here.\nFFMPEG_BIN = APP_ROOT / \"bin\" / \"ffmpeg\" / \"bin\" # All modules need this\nRUBBERBAND_BIN = APP_ROOT / \"bin\" / \"rubberband\" # This is for adjusting pitch on TTS gens that have altered speeds\nESPEAK_DIR = APP_ROOT / \"bin\" / \"espeak-ng\" # Kokoro TTS needs this\n\n\n#WHISPER_PATH = APP_ROOT / \"models\" / \"base.en.pt\" # fast, ~1.5 GB VRAM - use this one for the GPU poors\nWHISPER_PATH = APP_ROOT / \"models\" / \"medium.en.pt\" # best quality, ~5 GB VRAM\n# WHISPER_PATH = APP_ROOT / \"models\" / \"large-v3.pt\" # ~10 GB VRAM of overkill\n\n# XTTS v2 TTS model path here\nMODEL_PATH = APP_ROOT / \"models\" / \"XTTS-v2\"\n\n# Fish Speech TTS paths\nFISH_REPO_DIR = Path(os.getenv(\"FISH_REPO_DIR\", APP_ROOT / \"fish-speech\"))\nFISH_MODEL_DIR = Path(os.getenv(\"FISH_MODEL_DIR\", APP_ROOT / \"models\" / \"fish-speech\"))\nFISH_TEXT2SEM_DIR = FISH_MODEL_DIR\nFISH_DAC_CKPT = FISH_MODEL_DIR / \"codec.pth\"\n\n#Kokoro TTS model paths, MUST have ESPEAK_DIR = APP_ROOT / \"bin\" / \"espeak-ng\" connected.\nKOKORO_MODEL_DIR = APP_ROOT / \"models\" / \"kokoro-82m\"\nDLL_PATH = ESPEAK_DIR / \"libespeak-ng.dll\"\nDATA_DIR = ESPEAK_DIR / \"espeak-ng-data\"\n\n# LocalSoundsAPI save directory\nPROJECTS_OUTPUT = APP_ROOT / \"projects_output\"\n\n# The local llama cpp needs to be hardcoded to LLM_DEVICE on start up \n# to which device to go to. Can be \"cpu\" for CPU.\nLLM_DEVICE = \"0\" \n# LLM_DIRECTORY wherever you keep your .gguf models. \n# I have this set to my LM Studio drive because my .ggufs are there.\nLLM_DIRECTORY = r\"E:\\LL STUDIO\" \n\n# This is the default API endpoint for LM Studio, change as needed.\nLMSTUDIO_API_BASE = \"http://127.0.0.1:1234/v1\"\n\n# path resolver for loading models, use this for universal paths, \n# Linux & MAC may need to fiddle with this here and maybe use it in the app.\ndef resolve_device(device_input):\n if device_input is None:\n return \"cuda:0\" if torch.cuda.is_available() else \"cpu\"\n\n inp = str(device_input).strip().lower()\n if inp == \"cpu\":\n return \"cpu\"\n\n if inp.startswith(\"cuda:\"):\n return inp\n try:\n idx = int(inp)\n if idx >= 0 and torch.cuda.is_available():\n if idx < torch.cuda.device_count():\n return f\"cuda:{idx}\"\n else:\n print(f\"[resolve_device] GPU {idx} out of range → using 0\")\n return \"cuda:0\"\n return \"cpu\" \n except ValueError:\n pass\n\n if inp.isdigit() is False and inp != \"cpu\":\n fallback = f\"cuda:{inp}\" if inp.isdigit() is False and inp != \"\" else \"cuda:0\"\n print(f\"[resolve_device] Weird input '{device_input}' → forcing {fallback}\")\n return fallback\n return \"cuda:0\" if torch.cuda.is_available() else \"cpu\"\n \n# These following settings are for setting each TTS chunks' padding and clipping detections and repair.\n# I don't think you need to adjust these, but if you hear words are being clipped or there's too\n# much silence between the chunks you adjust them here.\n# XTTS\nXTTS_PADDING_SECONDS = 0.5\nXTTS_CLIPPING_THRESHOLD = 0.95\nXTTS_TARGET_LUFS = -23.0\nXTTS_TRIM_DB = -35\nXTTS_MIN_SILENCE = 500\nXTTS_FRONT_PROTECT = 100\nXTTS_END_PROTECT = 800\nXTTS_FRONT_PAD = 0.0\nXTTS_INTER_PAUSE = 0.25\n\n\n# Fish Speech\nFISH_PADDING_SECONDS = 0.5\nFISH_CLIPPING_THRESHOLD = 0.95\nFISH_TARGET_LUFS = -23.0\nFISH_TRIM_DB = -40\nFISH_MIN_SILENCE = 400\nFISH_FRONT_PROTECT = 80\nFISH_END_PROTECT = 600\nFISH_FRONT_PAD = 0.0\nFISH_INTER_PAUSE = 0.2\n\n# Kokoro\nKOKORO_PADDING_SECONDS = 0.5\nKOKORO_CLIPPING_THRESHOLD = 0.95\nKOKORO_TARGET_LUFS = -23.0\nKOKORO_TRIM_DB = -40\nKOKORO_MIN_SILENCE = 300\nKOKORO_FRONT_PROTECT = 250\nKOKORO_END_PROTECT = 1100\nKOKORO_FRONT_PAD = 0.15\nKOKORO_INTER_PAUSE = 0.3\n\n# Kokoro – Voice-specific TARGET_LUFS cheat sheet (paste under your Kokoro settings)\n# → Pick the line that matches your voice and set KOKORO_TARGET_LUFS to that value\n# → Also make sure the final \"audio = audio * 0.89\" line is disabled for Kokoro\n\n# KOKORO_TARGET_LUFS = -26.0 # am_onyx, af_bella, ef_onyx, ef_bella, ef_adam, ef_emma → hottest voices, use this 95% of the time\n# KOKORO_TARGET_LUFS = -25.0 # am_adam, af_emma → slightly cooler but still modern, safe and loud\n# KOKORO_TARGET_LUFS = -23.0 # old em_* voices only (em_alice, em_john, etc.) → rarely used in 2025\n\n# when a chunk fails for whatever reason in a TTS job, if a chunk fails\n# you can set this to try it again. 3 times is enough, if that doesn't\n# work there is something wrong with that chunk and must be corrected\n# manually on the job.json file in the project directory you created.\nXTTS_AUTO_TRIGGER_JOB_RECOVERY_ATTEMPTS = 3\nFISH_AUTO_TRIGGER_JOB_RECOVERY_ATTEMPTS = 3\nKOKORO_AUTO_TRIGGER_JOB_RECOVERY_ATTEMPTS = 3\n\n# OpenRouter key here. Visit them if you need a key, it's not free FYI\n# https://openrouter.ai/\nOPENROUTER_API_KEY = \"sk-or-v1-[your-key-numbers]\" "}}}}