{"record":{"id":"999b2afc75efc701","repo":"SubtitleEdit/subtitleedit","slug":"crispasr-exited-with-code-process-exitcode-err","errorCode":null,"errorMessage":"CrispASR exited with code {process.ExitCode}: {Error}","messagePattern":"CrispASR exited with code (.+?): (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/libuilogic/AutoTranslate/CrispAsrMadladTranslate.cs","lineNumber":131,"sourceCode":"                        {\n                            process.Kill();\n                        }\n                    }\n                    catch\n                    {\n                        // ignore - process may have already exited\n                    }\n\n                    exitedSource.TrySetCanceled();\n                }))\n                {\n                    await exitedSource.Task.ConfigureAwait(false);\n                }\n\n                if (process.ExitCode != 0)\n                {\n                    Error = errorBuilder.ToString().Trim();\n                    throw new Exception($\"CrispASR exited with code {process.ExitCode}: {Error}\");\n                }\n\n                return outputBuilder.ToString().Trim();\n            }\n        }\n\n        private static List<TranslationPair> ListLanguages()\n        {\n            var result = new List<TranslationPair>();\n            var seen = new HashSet<string>();\n            foreach (var culture in Utilities.GetSubtitleLanguageCultures(false))\n            {\n                if (!string.IsNullOrEmpty(culture.TwoLetterISOLanguageName) && seen.Add(culture.TwoLetterISOLanguageName))\n                {\n                    result.Add(new TranslationPair(culture.EnglishName, culture.TwoLetterISOLanguageName));\n                }\n            }\n","sourceCodeStart":113,"sourceCodeEnd":149,"githubUrl":"https://github.com/SubtitleEdit/subtitleedit/blob/17a9f0748781032255db3526b7215d2fb891e3af/src/libuilogic/AutoTranslate/CrispAsrMadladTranslate.cs#L113-L149","documentation":"Thrown after the CrispASR command-line process (madlad backend) exits with a non-zero code. The executable and model paths are validated earlier (lines 47-57), so this fires only when the process launched successfully but failed at runtime. The captured stderr is appended to the message.","triggerScenarios":"Translate() spawns CrispASR with args --backend madlad, a model path, the source/target language codes, and the trimmed input text; the process runs to completion but process.ExitCode != 0. Also fires when the CancellationToken triggers process.Kill() and the exit code is non-zero on some platforms.","commonSituations":"Missing CUDA/runtime DLLs on Windows; a corrupted or wrong-architecture model file; language codes CrispASR does not accept (it expects ISO codes the MADLAD model knows); input text exceeding the model's token budget; antivirus blocking the executable mid-run; permission denied reading the model.","solutions":["Run the exact CrispASR command from the error's stderr manually in a terminal to see the native error.","Verify the model file matches the CrispASR version (re-download via the Download button).","Confirm the source/target language codes are valid two-letter ISO 639-1 codes supported by MADLAD-400.","Install required runtime dependencies (CUDA toolkit, Visual C++ Redistributable on Windows).","Shorten the input text (MaxCharacters is 1000) and retry."],"exampleFix":"// before\nError = errorBuilder.ToString().Trim();\nthrow new Exception($\"CrispASR exited with code {process.ExitCode}: {Error}\");\n\n// after - surface exit code distinctly and log stderr for diagnostics\nError = errorBuilder.ToString().Trim();\nSeLogger.Error($\"CrispASR exited with code {process.ExitCode}. Args: {startInfo.Arguments}. Stderr: {Error}\");\nthrow new Exception($\"CrispASR exited with code {process.ExitCode}: {Error}\", new InvalidOperationException(Error));","handlingStrategy":"try-catch","validationCode":"// Validate inputs before launching the process\nif (string.IsNullOrWhiteSpace(_executablePath) || !File.Exists(_executablePath))\n    throw new InvalidOperationException(\"CrispASR executable path is invalid: \" + _executablePath);\nif (string.IsNullOrWhiteSpace(_modelPath) || !File.Exists(_modelPath))\n    throw new InvalidOperationException(\"CrispASR model path is invalid: \" + _modelPath);\nif (string.IsNullOrWhiteSpace(sourceLanguageCode) || string.IsNullOrWhiteSpace(targetLanguageCode))\n    throw new ArgumentException(\"Source and target language codes must be set.\");\nif (text.Length > MaxCharacters)\n    throw new ArgumentException($\"Input text ({text.Length} chars) exceeds MaxCharacters ({MaxCharacters}).\");","typeGuard":"public static bool IsCrispAsrReady(string exePath, string modelPath) =>\n    !string.IsNullOrWhiteSpace(exePath) && File.Exists(exePath) &&\n    !string.IsNullOrWhiteSpace(modelPath) && File.Exists(modelPath);","tryCatchPattern":"try\n{\n    return await translator.Translate(text, src, tgt, token);\n}\ncatch (Exception ex) when (ex.Message.Contains(\"CrispASR exited with code\"))\n{\n    // Surface stderr to the user; offer to re-download the model or check language codes\n    logger.Error(ex, \"CrispASR failed: {Message}\");\n    throw new InvalidOperationException(\"CrispASR runtime failure - check the model, language codes, and dependencies.\", ex);\n}","preventionTips":["Run CrispASR manually once after install to confirm the runtime deps and model load.","Pre-validate language codes against the model's supported set before batch translation.","Chunk input under MaxCharacters (1000) to avoid token-budget crashes.","Log the full command line + stderr on every CrispASR failure for fast triage."],"tags":["process","external-tool","translation","configuration"],"backgroundTag":null,"analyzedSha":"17a9f0748781032255db3526b7215d2fb891e3af","analyzedAt":"2026-08-13T18:11:43.374Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}