{"record":{"id":"4a9b6ff2b8fa4ae1","repo":"SubtitleEdit/subtitleedit","slug":"cosyvoice3-crispasr-the-crispasr-server-crashe","errorCode":null,"errorMessage":"CosyVoice3 (CrispASR) — the crispasr server crashed during synthesis.","messagePattern":"CosyVoice3 \\(CrispASR\\) — the crispasr server crashed during synthesis\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/ui/Features/Video/TextToSpeech/Engines/CosyVoice3CrispAsr.cs","lineNumber":588,"sourceCode":"            response = await HttpClient.PostAsync($\"{ServerBaseUrl}/v1/audio/speech\", content, cancellationToken);\n        }\n        catch (HttpRequestException ex)\n        {\n            var serverLog = SnapshotServerLog();\n            var launchCommand = _serverLaunchCommand;\n            var died = _serverProcess?.HasExited == true;\n            if (died)\n            {\n                StopServerInternal();\n            }\n\n            var failMsg = $\"CosyVoice3 (CrispASR) request failed — Voice: {cosyVoice}, Text: {text}, \"\n                + $\"RequestJson: {body}, ServerExited: {died}, ServerLog: {serverLog}\"\n                + LaunchCmdSuffix(launchCommand);\n            Se.LogError(ex, failMsg);\n            Se.WriteToolsLog(failMsg);\n\n            throw new InvalidOperationException(\n                (died\n                    ? \"CosyVoice3 (CrispASR) — the crispasr server crashed during synthesis.\"\n                    : \"CosyVoice3 (CrispASR) request failed — the connection to the crispasr server was dropped.\")\n                + (string.IsNullOrEmpty(serverLog) ? string.Empty : $\"{Environment.NewLine}Server log:{Environment.NewLine}{serverLog}\")\n                + LaunchCmdSuffix(launchCommand),\n                ex);\n        }\n\n        using (response)\n        {\n            if (!response.IsSuccessStatusCode)\n            {\n                var errorBody = await SafeReadErrorAsync(response, cancellationToken);\n                var serverLog = SnapshotServerLog();\n                var launchCommand = _serverLaunchCommand;\n                var errMsg = $\"CosyVoice3 (CrispASR) server error {(int)response.StatusCode} {response.StatusCode} — \"\n                    + $\"Voice: {cosyVoice}, Text: {text}, RequestJson: {body}, \"\n                    + $\"ResponseBody: {errorBody}, ServerLog: {serverLog}\"","sourceCodeStart":570,"sourceCodeEnd":606,"githubUrl":"https://github.com/SubtitleEdit/subtitleedit/blob/17a9f0748781032255db3526b7215d2fb891e3af/src/ui/Features/Video/TextToSpeech/Engines/CosyVoice3CrispAsr.cs#L570-L606","documentation":"InvalidOperationException from CosyVoice3CrispAsr.Speak's HttpRequestException catch: the POST to /v1/audio/speech failed AND _serverProcess.HasExited is true, so the request failure is interpreted as the crispasr server having crashed mid-synthesis. The original HttpRequestException is chained as InnerException and the server log is appended.","triggerScenarios":"During synthesis, HttpClient.PostAsync raises HttpRequestException; the catch checks _serverProcess?.HasExited == true (server died) → the 'crashed during synthesis' branch fires; StopServerInternal is called to reap it.","commonSituations":"Synthesis OOM killing the server; a model/voice combination that crashes the backend on a particular input; the server hit an upstream assert and exited while streaming the response.","solutions":["Inspect the appended 'Server log' for the crash cause (usually a backend assert or OOM).","Retry with a different voice/preset or a shorter input text to rule out input-triggered crashes.","Re-download the CosyVoice3 model bundle in case of file corruption.","If on limited RAM, switch to the Q4K model key to lower memory pressure.","Track the upstream CrispASR fix for the asserted backend and re-download when released."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// Before synthesis, confirm the server is alive (cheap relative to a failed synth).\nif (cosyVoice3Engine is CosyVoice3CrispAsr cv3 && !cv3.IsServerAlive()) {\n    cv3.StopServer(); // force a clean relaunch on next Speak\n}","typeGuard":null,"tryCatchPattern":"try { await cosyVoice3Engine.Speak(text, out, voice, lang, region, model, ct); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"server crashed during synthesis\", StringComparison.Ordinal))\n{\n    Se.WriteToolsLog(\"CosyVoice3 server crashed mid-synth; retrying once after relaunch.\", true);\n    CosyVoice3CrispAsr.StopServer();\n    await cosyVoice3Engine.Speak(text, out, voice, lang, region, model, ct);\n}","preventionTips":["Use the Q4K model key on memory-constrained hosts to avoid OOM kills.","Keep inputs reasonable; very long text can trigger backend asserts.","Re-download the CosyVoice3 bundle on any checksum/corruption suspicion."],"tags":["tts","cosyvoice3","crispasr","server-crash","synthesis","http-request-exception"],"backgroundTag":null,"analyzedSha":"17a9f0748781032255db3526b7215d2fb891e3af","analyzedAt":"2026-08-13T18:11:43.374Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}