VoiceStudio is the open-source, fully-local ElevenLabs alternative — voice cloning, voice design, video dubbing, dictation, transcription & audiobook creation in 646 languages.
Python aiaudiobookcudadubbingelevenlabs-alternativehuggingfacelocal-firstmlxomnivoice-studiospeech-to-texttext-to-speechtranscriptiontranslatettsvoice-aivoice-cloningvoice-generationvoicestudioworkflow
fix(generate): log the origin of a failed generation and offer another GPU on OOM
velixio8af9c88b6650
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex abbe0d4ad..cb3083b53 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -20,6 +20,10 @@ metadata and the backend fallback mirror it.- Contributor guides and the pull request template explain how to sign the CLA before opening a first pull request (#2676)+### Fixed++- A "Generation failed" log line now says where it was raised and which error caused it, and the out-of-memory advice mentions picking another GPU, so these reports can be told apart (#2895, #2684, #2666, #2626, #2622, #2580)+### CI- Desktop request-guard self-tests stay deterministic when app requests arrive during cleanup (#2676)diff --git a/backend/api/routers/generation.py b/backend/api/routers/generation.pyindex c7d645c16..4f7f8fc7c 100644--- a/backend/api/routers/generation.py+++ b/backend/api/routers/generation.py@@ -2377,11 +2377,13 @@ async def generate_speech(# diagnostic bundle and opaque to the user (#1607). The raw# exception is NOT logged: it can carry a reference-clip path or# a provider secret, and only the journal scrubs before storing.+ from core.public_errors import exception_origin, stream_generation_failure++ _origin = exception_origin(exc)logger.error(- "Streaming generation failed unexpectedly (class=%s)",- type(exc).__name__,+ "Streaming generation failed unexpectedly (class=%s%s)",+ type(exc).__name__, f"; {_origin}" if _origin else "",)- from core.public_errors import stream_generation_failurefrom core import error_journalerror_journal.record(diff --git a/backend/core/failure.py b/backend/core/failure.pyindex 90abd4156..4f2e47efd 100644--- a/backend/core/failure.py+++ b/backend/core/failure.py@@ -123,7 +123,7 @@ def invalid_media_file_detail() -> dict[str, str]:# One-line "what to do" per docs-taxonomy key. Keys mirror error_docs_map's# taxonomy; the docs URL itself stays owned by error_docs_map._HINTS: dict[str, str] = {- "GPU_OOM": "Close other GPU-heavy apps or unload models, then retry. You can also choose CPU in Settings → Performance & Device or select a smaller TTS engine.",+ "GPU_OOM": "Close other GPU-heavy apps or unload models, then retry. If another program is holding most of the GPU, or this computer has a second GPU, pick a different one in Settings → Performance & Device. You can also choose CPU there or select a smaller TTS engine.","GPU_ARCH_UNSUPPORTED": "This PyTorch build does not support your GPU. Choose CPU in Settings → Performance & Device, or install a compatible PyTorch build.",# #2462: the HOST ran out of RAM, not a GPU. On a CPU-only machine there is# no device to spill to, so *every* out-of-memory failure there is thisdiff --git a/backend/core/public_errors.py b/backend/core/public_errors.pyindex 244a8f7d8..c0a5a16ef 100644--- a/backend/core/public_errors.py+++ b/backend/core/public_errors.py@@ -15,6 +15,40 @@ _PROVIDER_DETAILS = {}+def exception_origin(error: object) -> str:+ """Where a failure was raised, as ``module:function:line`` plus the cause type.++ The streaming/engine failure log line deliberately withholds the exception+ message (it can carry a path or a secret), which left every auto-filed+ "Generation failed" report (#2895, #2684, #2666, #2626, #2622, #2580)+ without anything to triage: different faults wrote the same line. The+ innermost frame's importable module name, function and line number are+ source-code identifiers, and the exception types along the ``__cause__`` /+ ``__context__`` chain are Python types; neither can contain user text.+ Never raises.+ """+ try:+ if not isinstance(error, BaseException):+ return ""+ tail = error.__traceback__+ while tail is not None and tail.tb_next is not None:+ tail = tail.tb_next+ parts = []+ if tail is not None:+ module = str(tail.tb_frame.f_globals.get("__name__", "?"))+ parts.append(f"at={module}:{tail.tb_frame.f_code.co_name}:{tail.tb_lineno}")+ chain, seen, current = [], 0, error.__cause__ or error.__context__+ while current is not None and seen < 4:+ chain.append(type(current).__name__)+ current = current.__cause__ or current.__context__+ seen += 1+ if chain:+ parts.append("caused_by=" + ">".join(chain))+ return "; ".join(parts)+ except Exception: # noqa: BLE001 - diagnostics must not replace the failure+ return ""++def provider_failure(kind: str) -> dict[str, str]:"""Return a stable provider error class and remediation message."""safe_kind = kind if kind in _PROVIDER_DETAILS else "error"@@ -240,7 +274,11 @@ def public_failure("""del tracebackerror_class = type(error).__name__ if isinstance(error, BaseException) else "Failure"- logger.error("%s (class=%s; details withheld)", log_message, error_class)+ origin = exception_origin(error)+ logger.error(+ "%s (class=%s%s; details withheld)",+ log_message, error_class, f"; {origin}" if origin else "",+ )return responsediff --git a/tests/test_generation_failure_origin.py b/tests/test_generation_failure_origin.pynew file mode 100644index 000000000..667c140b2--- /dev/null+++ b/tests/test_generation_failure_origin.py@@ -0,0 +1,49 @@+"""Generation failures log where they were raised, never what they said.++#2895/#2684/#2666/#2626/#2622/#2580 were six reports of the identical floor+message and an identical log line (``class=RuntimeError``), so nothing in them+could separate an engine bug from a GPU that another program had filled.+"""+import logging+import sys++sys.path.insert(0, "backend")++from core import failure # noqa: E402+from core import public_errors # noqa: E402+++def _raise_deep():+ try:+ raise KeyError("/home/alice/secret-voice.wav")+ except KeyError as inner:+ raise RuntimeError("token sk-abc123 at /home/alice/x.wav") from inner+++def test_origin_names_frame_and_cause_but_no_message():+ try:+ _raise_deep()+ except RuntimeError as e:+ origin = public_errors.exception_origin(e)+ assert origin.startswith("at=")+ assert "_raise_deep" in origin and "caused_by=KeyError" in origin+ for leaked in ("alice", "sk-abc123", "secret-voice"):+ assert leaked not in origin+++def test_origin_never_raises_on_non_exceptions():+ assert public_errors.exception_origin("boom") == ""+++def test_public_failure_log_carries_origin(caplog):+ log = logging.getLogger("t")+ try:+ _raise_deep()+ except RuntimeError as e:+ with caplog.at_level(logging.ERROR, logger="t"):+ public_errors.public_failure(log, "Boom", e, response="x")+ assert "_raise_deep" in caplog.text and "alice" not in caplog.text+++def test_gpu_oom_hint_offers_another_gpu():+ assert "different one in Settings" in failure._HINTS["GPU_OOM"]