{"record":{"id":"f34250a0d413bd9d","repo":"SubtitleEdit/subtitleedit","slug":"f5-tts-crispasr-synthesis-failed-int-response","errorCode":null,"errorMessage":"F5-TTS (CrispASR) synthesis failed ({(int)response.StatusCode}): {errorBody}","messagePattern":"F5-TTS \\(CrispASR\\) synthesis failed \\((.+?)\\): (.+?)","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/ui/Features/Video/TextToSpeech/Engines/F5TtsCrispAsr.cs","lineNumber":446,"sourceCode":"                + (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 = $\"F5-TTS (CrispASR) server error {(int)response.StatusCode} {response.StatusCode} — \"\n                    + $\"Voice: {f5Voice}, Text: {text}, RequestJson: {body}, \"\n                    + $\"ResponseBody: {errorBody}, ServerLog: {serverLog}\"\n                    + LaunchCmdSuffix(launchCommand);\n                Se.LogError(errMsg);\n                Se.WriteToolsLog(errMsg);\n                throw new InvalidOperationException(\n                    $\"F5-TTS (CrispASR) synthesis failed ({(int)response.StatusCode}): {errorBody}\"\n                    + (string.IsNullOrEmpty(serverLog) ? string.Empty : $\"{Environment.NewLine}Server log:{Environment.NewLine}{serverLog}\")\n                    + LaunchCmdSuffix(launchCommand));\n            }\n\n            await using var fileStream = File.Create(outputFileName);\n            await using var contentStream = await response.Content.ReadAsStreamAsync(cancellationToken);\n            await contentStream.CopyToAsync(fileStream, cancellationToken);\n        }\n\n        return new TtsResult(outputFileName, text);\n    }\n\n    private static string TryReadRefText(string wavPath)\n    {\n        try\n        {\n            var sidecar = Path.ChangeExtension(wavPath, \".txt\");","sourceCodeStart":428,"sourceCodeEnd":464,"githubUrl":"https://github.com/SubtitleEdit/subtitleedit/blob/17a9f0748781032255db3526b7215d2fb891e3af/src/ui/Features/Video/TextToSpeech/Engines/F5TtsCrispAsr.cs#L428-L464","documentation":"InvalidOperationException from F5TtsCrispAsr.Speak when /v1/audio/speech returns a non-success HTTP status. The numeric status, the response body (SafeReadErrorAsync), and the server log are folded into the message; the detailed diagnostic is also written via Se.LogError/Se.WriteToolsLog.","triggerScenarios":"crispasr returns 4xx/5xx for the synthesis request — HTTP 400 for a malformed request or a voice path that triggers the path-traversal guard, 422 for unsupported input, 500 for a backend fault that did not kill the process, 503 while still loading.","commonSituations":"The deliberate non-sending of the 'voice'/'ref_text' field was fixed so the request stays clean — but a stale server build could still reject paths; ref-text missing for a clone; the server still warming up (503); a backend bug returning 500.","solutions":["Read the status: 4xx → fix the request payload; 5xx → server/backend fault.","Confirm the reference WAV is 24 kHz mono and the .txt sidecar holds the spoken transcription.","On 503, wait for the server to finish loading and retry.","Inspect 'Server log' for the backend stack trace behind a 500.","Ensure CrispASR is current — older builds rejected absolute voice paths (HTTP 400 path-traversal guard)."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Validate reference WAV + sidecar before posting.\nif (voice.EngineVoice is F5TtsVoice f5 && (string.IsNullOrEmpty(f5.FilePath) || !File.Exists(Path.ChangeExtension(f5.FilePath, \".txt\"))))\n    return new TtsResult { Text = text, FileName = string.Empty, Error = true, ErrorMessage = \"F5-TTS needs a reference WAV + .txt sidecar.\" };","typeGuard":null,"tryCatchPattern":"try { await f5TtsEngine.Speak(text, out, voice, lang, region, model, ct); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"synthesis failed (\", StringComparison.Ordinal))\n{\n    var code = ExtractStatusCode(ex.Message);\n    if (code == 503) { await Task.Delay(TimeSpan.FromSeconds(5), ct); await f5TtsEngine.Speak(text, out, voice, lang, region, model, ct); }\n    else Se.WriteToolsLog($\"F5-TTS synthesis HTTP {code}: {ex.Message}\", true);\n}","preventionTips":["Ensure CrispASR is current — older builds rejected absolute voice paths (HTTP 400).","Always pair the reference WAV with a .txt transcription sidecar.","On 503, wait for warm-up and retry rather than failing immediately."],"tags":["tts","f5-tts","crispasr","http-error","synthesis","request-payload"],"backgroundTag":null,"analyzedSha":"17a9f0748781032255db3526b7215d2fb891e3af","analyzedAt":"2026-08-13T18:11:43.374Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}