{"record":{"id":"a3c2934588daf0f4","repo":"SubtitleEdit/subtitleedit","slug":"crispasr-f5-tts-exited-during-startup-code-exi","errorCode":null,"errorMessage":"crispasr (f5-tts) exited during startup (code {exitCode}). Output: {tail}{LaunchCmdSuffix}","messagePattern":"crispasr \\(f5-tts\\) exited during startup \\(code (.+?)\\)\\. Output: (.+?)(.+?)","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/ui/Features/Video/TextToSpeech/Engines/F5TtsCrispAsr.cs","lineNumber":637,"sourceCode":"            HookProcessExitOnce();\n\n            // First-run auto-download (~953 MB talker) needs a generous timeout.\n            var deadline = DateTime.UtcNow.AddMinutes(hasLocalTalker ? 5 : 20);\n            while (DateTime.UtcNow < deadline)\n            {\n                ct.ThrowIfCancellationRequested();\n                if (process.HasExited)\n                {\n                    var tail = SnapshotServerLog();\n                    var exitCode = process.ExitCode;\n                    var exitedLaunchCommand = _serverLaunchCommand;\n                    _serverProcess = null;\n                    _serverPort = 0;\n                    _serverLaunchCommand = null;\n                    _serverModelKey = null;\n                    _serverVoicePath = null;\n                    _serverRefText = null;\n                    throw new InvalidOperationException(\n                        $\"crispasr (f5-tts) exited during startup (code {exitCode}). Output: {tail}\"\n                        + LaunchCmdSuffix(exitedLaunchCommand));\n                }\n                if (await ProbeHealthAsync(port, TimeSpan.FromSeconds(2), ct))\n                {\n                    return;\n                }\n                await Task.Delay(TimeSpan.FromSeconds(1), ct);\n            }\n\n            var lastOutput = SnapshotServerLog();\n            var timeoutLaunchCommand = _serverLaunchCommand;\n            StopServerInternal();\n            throw new TimeoutException(\n                $\"crispasr (f5-tts) did not report healthy within {(hasLocalTalker ? 5 : 20)} minutes. Last output: {lastOutput}\"\n                + LaunchCmdSuffix(timeoutLaunchCommand));\n        }\n        finally","sourceCodeStart":619,"sourceCodeEnd":655,"githubUrl":"https://github.com/SubtitleEdit/subtitleedit/blob/17a9f0748781032255db3526b7215d2fb891e3af/src/ui/Features/Video/TextToSpeech/Engines/F5TtsCrispAsr.cs#L619-L655","documentation":"The F5-TTS engine spawns the `crispasr` binary as a loopback child server and polls its `/health` endpoint. This InvalidOperationException is thrown from the startup loop in EnsureServerRunningAsync when `process.HasExited` becomes true before the first successful health probe — the server died while still initializing. The message carries the raw exit code, the last 2000 chars of captured stdout/stderr, and the exact launch command so you can reproduce the failure manually.","triggerScenarios":"Calling Speak() (→ EnsureServerRunningAsync) when the talker/codec GGUF is missing or corrupt and `--auto-download` fails; when the f5-tts backend hits a CUDA/runtime error at boot; when antivirus quarantines `crispasr.exe`; when a stale file lock holds the model open. The check fires only inside the 5/20-minute startup window before ProbeHealthAsync ever succeeds.","commonSituations":"First run after install where the ~953 MB talker download was interrupted; CrispASR upgraded to a version whose CLI flags changed; a GPU driver update broke the bundled CUDA runtime; corporate AV silently killing the process.","solutions":["Read the `Output:` tail in the message — the server's own stderr names the real cause (e.g. `CUDA error: no kernel image`, `model file not found`).","Copy the `Launch command:` line and run it in a terminal to see the full untruncated error.","Verify the talker GGUF at the path from GetTalkerPath(modelKey) is non-zero bytes; if missing, let `--auto-download` re-fetch on a stable connection.","Add the CrispASR install folder to antivirus exclusions and retry.","If the GPU/CUDA stack is broken, install a CPU-only CrispASR build or update the GPU driver to match the release notes."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Pre-flight: confirm exe + talker model before invoking Speak\nvar exe = engine.GetCrispAsrExecutable(); // via reflection/internal access if exposed\nif (!File.Exists(exe)) { WarnUser(\"Install CrispASR first\"); return; }\nif (!engine.HasLocalModel(modelKey)) { WarnUser(\"First run will download ~953 MB; keep the network stable.\"); }","typeGuard":null,"tryCatchPattern":"try\n{\n    var result = await f5Engine.Speak(text, outFolder, voice, lang, region, model, ct);\n}\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"exited during startup\"))\n{\n    // Surface exit code + Output tail to the user; offer a manual command to reproduce.\n    ShowDiagnostics(ex.Message);\n    // Do NOT auto-retry in a tight loop — the cause (missing model, AV, CUDA) must be fixed first.\n}","preventionTips":["Pre-stage the talker GGUF locally so the 5-minute startup path is used and no download can fail mid-boot.","Add the CrispASR install folder to antivirus exclusions.","Run the engine once after install on the user's machine to surface boot errors before a real job.","Capture Se.WriteToolsLog output during first run to diagnose exit codes quickly."],"tags":["f5-tts","crispasr","process-startup","server","tts"],"backgroundTag":null,"analyzedSha":"17a9f0748781032255db3526b7215d2fb891e3af","analyzedAt":"2026-08-13T18:11:43.374Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}