mirror of
https://github.com/denizsafak/abogen.git
synced 2026-07-18 13:40:27 +02:00
feat: Add environment variables for voice cache and Hugging Face directory in Docker setup
This commit is contained in:
+5
-2
@@ -47,8 +47,11 @@ VOLUME ["/data"]
|
|||||||
|
|
||||||
ENV ABOGEN_UPLOAD_ROOT=/data/uploads \
|
ENV ABOGEN_UPLOAD_ROOT=/data/uploads \
|
||||||
ABOGEN_OUTPUT_ROOT=/data/outputs \
|
ABOGEN_OUTPUT_ROOT=/data/outputs \
|
||||||
ABOGEN_TEMP_DIR=/data/cache
|
ABOGEN_TEMP_DIR=/data/cache \
|
||||||
|
ABOGEN_VOICE_CACHE_DIR=/data/voice-cache \
|
||||||
|
HF_HOME=/data/huggingface \
|
||||||
|
HUGGINGFACE_HUB_CACHE=/data/huggingface/hub
|
||||||
|
|
||||||
RUN mkdir -p /data/uploads /data/outputs /data/cache
|
RUN mkdir -p /data/uploads /data/outputs /data/cache /data/voice-cache /data/huggingface
|
||||||
|
|
||||||
CMD ["abogen"]
|
CMD ["abogen"]
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import os
|
||||||
import threading
|
import threading
|
||||||
from typing import Callable, Dict, Iterable, Optional, Set, Tuple
|
from typing import Callable, Dict, Iterable, Optional, Set, Tuple
|
||||||
|
|
||||||
@@ -53,6 +54,11 @@ def ensure_voice_assets(
|
|||||||
if hf_hub_download is None:
|
if hf_hub_download is None:
|
||||||
raise RuntimeError("huggingface_hub is required to cache voices")
|
raise RuntimeError("huggingface_hub is required to cache voices")
|
||||||
|
|
||||||
|
effective_cache_dir = cache_dir
|
||||||
|
if effective_cache_dir is None:
|
||||||
|
env_cache_dir = os.environ.get("ABOGEN_VOICE_CACHE_DIR", "").strip()
|
||||||
|
effective_cache_dir = env_cache_dir or None
|
||||||
|
|
||||||
targets = _normalize_targets(voices)
|
targets = _normalize_targets(voices)
|
||||||
if not targets:
|
if not targets:
|
||||||
return set(), {}
|
return set(), {}
|
||||||
@@ -70,7 +76,7 @@ def ensure_voice_assets(
|
|||||||
downloaded_flag = _ensure_single_voice_asset(
|
downloaded_flag = _ensure_single_voice_asset(
|
||||||
voice_id,
|
voice_id,
|
||||||
repo_id=repo_id,
|
repo_id=repo_id,
|
||||||
cache_dir=cache_dir,
|
cache_dir=effective_cache_dir,
|
||||||
)
|
)
|
||||||
except Exception as exc: # pragma: no cover - network variance
|
except Exception as exc: # pragma: no cover - network variance
|
||||||
errors[voice_id] = str(exc)
|
errors[voice_id] = str(exc)
|
||||||
|
|||||||
@@ -23,6 +23,9 @@ services:
|
|||||||
ABOGEN_OUTPUT_DIR: "/data/outputs"
|
ABOGEN_OUTPUT_DIR: "/data/outputs"
|
||||||
ABOGEN_OUTPUT_ROOT: "/data/outputs"
|
ABOGEN_OUTPUT_ROOT: "/data/outputs"
|
||||||
ABOGEN_TEMP_DIR: "/data/cache"
|
ABOGEN_TEMP_DIR: "/data/cache"
|
||||||
|
ABOGEN_VOICE_CACHE_DIR: "/data/voice-cache"
|
||||||
|
HF_HOME: "/data/huggingface"
|
||||||
|
HUGGINGFACE_HUB_CACHE: "/data/huggingface/hub"
|
||||||
HOME: "/tmp/abogen-home"
|
HOME: "/tmp/abogen-home"
|
||||||
# --- GPU support -----------------------------------------------------
|
# --- GPU support -----------------------------------------------------
|
||||||
# These settings assume the NVIDIA Container Toolkit is installed.
|
# These settings assume the NVIDIA Container Toolkit is installed.
|
||||||
|
|||||||
Reference in New Issue
Block a user