SubtitleEdit/subtitleedit · error · InvalidOperationException

Chatterbox TTS synthesis failed ({(int)response.StatusCode})

Error message

Chatterbox TTS synthesis failed ({(int)response.StatusCode}): {errorBody}

What it means

HTTP non-success from /v1/audio/speech with LooksLikeCloneReferenceRejected false — generic backend failure. The body and the captured serverLog are appended so the real cause is visible. This is the fallback prefix path of the same throw as 193.

Source

Thrown at src/ui/Features/Video/TextToSpeech/Engines/ChatterboxTtsCpp.cs:436

                var serverLog = SnapshotServerLog();
                var launchCommand = _serverLaunchCommand;
                var errMsg = $"Chatterbox TTS server error {(int)response.StatusCode} {response.StatusCode} - "
                    + $"Voice: {chatterboxVoice}, Text: {text}, RequestJson: {body}, "
                    + $"ResponseBody: {errorBody}, ServerLog: {serverLog}"
                    + LaunchCmdSuffix(launchCommand);
                Se.LogError(errMsg);
                Se.WriteToolsLog(errMsg);

                // The HTTP body only ever says "backend returned empty audio" - the reason the
                // backend produced none is in the server log, so name it (#13508).
                var prefix = LooksLikeCloneReferenceRejected(serverLog)
                    ? $"Chatterbox TTS could not use the reference voice \"{Path.GetFileName(chatterboxVoice.FilePath)}\" for cloning: "
                      + $"CrispASR needs a {CloneReferenceSampleRate / 1000} kHz mono WAV and re-encoding this one did not produce that. "
                      + "Re-import the voice, or convert it yourself with "
                      + $"`ffmpeg -i <input> -ar {CloneReferenceSampleRate} -ac 1 -c:a pcm_s16le <output>.wav`. "
                    : string.Empty;

                throw new InvalidOperationException(
                    prefix
                    + $"Chatterbox TTS synthesis failed ({(int)response.StatusCode}): {errorBody}"
                    + (string.IsNullOrEmpty(serverLog) ? string.Empty : $"{Environment.NewLine}Server log:{Environment.NewLine}{serverLog}")
                    + LaunchCmdSuffix(launchCommand));
            }

            await using var fileStream = File.Create(outputFileName);
            await using var contentStream = await response.Content.ReadAsStreamAsync(cancellationToken);
            await contentStream.CopyToAsync(fileStream, cancellationToken);
        }

        return new TtsResult(outputFileName, text);
    }

    /// <summary>
    /// Builds the <c>/v1/audio/speech</c> JSON payload. Extracted so the cloning attestations are
    /// unit-testable without a running crispasr server.
    /// </summary>

View on GitHub (pinned to 17a9f07487)

Solutions

  1. Inspect errorBody and the appended serverLog in the message.
  2. Confirm the voice file exists in GetSetVoicesFolder() (the server looks it up relative to cwd).
  3. Confirm the model is actually loaded (check tools log for startup errors).
  4. Retry after restarting the server.
Defensive patterns

Strategy: try-catch

Validate before calling

if (!File.Exists(Path.Combine(GetSetVoicesFolder(), Path.GetFileName(chatterboxVoice.FilePath))))
    return Invalid("voice file not present in voices folder");

Try / catch

try { await chatterbox.Speak(...); }
catch (InvalidOperationException ex) when (ex.Message.Contains("Chatterbox TTS synthesis failed"))
{ /* inspect errorBody + serverLog; verify voice file + model load */ }

Prevention

When it happens

Trigger: crispasr returns non-2xx for any reason other than reference rejection: voice file missing from the working directory, model not loaded, malformed request body, internal 500.

Common situations: Voice file not present in the voices folder (server resolves `voice` relative to its cwd); model failed to load but the endpoint still answered 500; request audio/text empty; version skew between client and server.

Related errors


AI-assisted analysis of SubtitleEdit/subtitleedit@17a9f07487 (2026-08-13). Data as JSON: /api/errors/e2171a879b24a3ce. Report an issue: GitHub.