mirror of
https://github.com/denizsafak/abogen.git
synced 2026-09-20 19:50:59 +02:00
feat: Enhance EPUB export by grouping chunks for rendering and adding group ID support
This commit is contained in:
+17
-6
@@ -10,6 +10,10 @@ except Exception: # pragma: no cover - import fallback
|
||||
hf_hub_download = None # type: ignore[assignment]
|
||||
LocalEntryNotFoundError = None # type: ignore[assignment]
|
||||
|
||||
if LocalEntryNotFoundError is None: # pragma: no cover - fallback for tests
|
||||
class LocalEntryNotFoundError(Exception):
|
||||
pass
|
||||
|
||||
from abogen.constants import VOICES_INTERNAL
|
||||
|
||||
_CACHE_LOCK = threading.Lock()
|
||||
@@ -116,11 +120,18 @@ def _ensure_single_voice_asset(
|
||||
raise RuntimeError("huggingface_hub is required to cache voices")
|
||||
|
||||
filename = f"voices/{voice_id}.pt"
|
||||
common_kwargs = {
|
||||
"repo_id": repo_id,
|
||||
"filename": filename,
|
||||
}
|
||||
if cache_dir is not None:
|
||||
common_kwargs["cache_dir"] = cache_dir
|
||||
|
||||
hf_hub_download(
|
||||
repo_id=repo_id,
|
||||
filename=filename,
|
||||
cache_dir=cache_dir,
|
||||
resume_download=True,
|
||||
)
|
||||
try:
|
||||
hf_hub_download(local_files_only=True, **common_kwargs)
|
||||
return False
|
||||
except LocalEntryNotFoundError:
|
||||
pass
|
||||
|
||||
hf_hub_download(resume_download=True, **common_kwargs)
|
||||
return True
|
||||
Reference in New Issue
Block a user