{"record":{"id":"2758f8e3adc044cf","repo":"fishaudio/fish-speech","slug":"str-result-error","errorCode":null,"errorMessage":"{str(result.error)}","messagePattern":"\\{str\\(result\\.error\\)\\}","errorType":"http","errorClass":"HTTPException","httpStatus":500,"severity":"error","filePath":"tools/server/inference.py","lineNumber":25,"sourceCode":"from fish_speech.utils.schema import ServeTTSRequest\n\nAMPLITUDE = 32768  # Needs an explaination\n\n\ndef inference_wrapper(req: ServeTTSRequest, engine: TTSInferenceEngine):\n    \"\"\"\n    Wrapper for the inference function.\n    Used in the API server.\n    \"\"\"\n    count = 0\n    for result in engine.inference(req):\n        match result.code:\n            case \"header\":\n                if isinstance(result.audio, tuple):\n                    yield result.audio[1]\n\n            case \"error\":\n                raise HTTPException(\n                    HTTPStatus.INTERNAL_SERVER_ERROR,\n                    content=str(result.error),\n                )\n\n            case \"segment\":\n                count += 1\n                if isinstance(result.audio, tuple):\n                    yield (result.audio[1] * AMPLITUDE).astype(np.int16).tobytes()\n\n            case \"final\":\n                count += 1\n                if isinstance(result.audio, tuple):\n                    yield result.audio[1]\n                return None  # Stop the generator\n\n    if count == 0:\n        raise HTTPException(\n            HTTPStatus.INTERNAL_SERVER_ERROR,","sourceCodeStart":7,"sourceCodeEnd":43,"githubUrl":"https://github.com/fishaudio/fish-speech/blob/befe4001745417f8c42131739d862b8a6fdbd15a/tools/server/inference.py#L7-L43","documentation":"The streaming TTS wrapper maps internal 'error' results from the inference pipeline to HTTP 500 with the underlying error string as content. It is a pass-through of failures inside model inference (loading, encoding, generation).","triggerScenarios":"Any exception raised during the serve pipeline — bad model path, unsupported request combination, OOM during generation — surfaces here as a 500 with the original message.","commonSituations":"Server started with mismatched model configs, corrupted audio references, CUDA OOM on long texts, or invalid parameters that pass request validation but break inference.","solutions":["Read the returned content string and the server logs — it names the real underlying error","Fix the root cause (model paths, memory, reference audio format)","Reduce text length / batch to rule out OOM"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    for chunk in stream_tts(client, req):\n        ...\nexcept HTTPError as e:\n    if e.response.status_code == 500:\n        log.error(e.response.text)  # underlying error string","preventionTips":["Ship a healthcheck that loads the model before serving","Validate model paths and reference audio at startup"],"tags":["api-server","http-500","inference"],"backgroundTag":"internal-server-error","analyzedSha":"befe4001745417f8c42131739d862b8a6fdbd15a","analyzedAt":"2026-08-27T21:31:45.703Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}