{"record":{"id":"77b96ccb7f353bce","repo":"harry0703/MoneyPrinterTurbo","slug":"mimo-tts-returned-empty-response","errorCode":null,"errorMessage":"MiMo TTS returned empty response","messagePattern":"MiMo TTS returned empty response","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"app/services/voice.py","lineNumber":1280,"sourceCode":"                f\"start mimo tts, model: {model_name}, voice: {voice_name}, try: {i + 1}\"\n            )\n            ensure_file_path_exists(voice_file)\n\n            client = OpenAI(api_key=api_key, base_url=base_url)\n            completion = client.chat.completions.create(\n                model=model_name,\n                messages=[\n                    {\"role\": \"user\", \"content\": style_prompt},\n                    {\"role\": \"assistant\", \"content\": text},\n                ],\n                audio={\n                    \"format\": \"wav\",\n                    \"voice\": voice_name,\n                },\n            )\n\n            if not completion or not getattr(completion, \"choices\", None):\n                raise ValueError(\"MiMo TTS returned empty response\")\n\n            message = completion.choices[0].message\n            audio = getattr(message, \"audio\", None)\n            audio_data = None\n            if isinstance(audio, dict):\n                audio_data = audio.get(\"data\")\n            elif audio is not None:\n                audio_data = getattr(audio, \"data\", None)\n\n            if not audio_data:\n                raise ValueError(\"MiMo TTS returned empty audio data\")\n\n            audio_bytes = base64.b64decode(audio_data)\n            audio_segment = AudioSegment.from_file(io.BytesIO(audio_bytes), format=\"wav\")\n\n            output_format = utils.parse_extension(voice_file) or \"mp3\"\n            if output_format == \"wav\":\n                with open(voice_file, \"wb\") as f:","sourceCodeStart":1262,"sourceCodeEnd":1298,"githubUrl":"https://github.com/harry0703/MoneyPrinterTurbo/blob/1f9f19c2021a68d04df228f33e9099a0c947f6f8/app/services/voice.py#L1262-L1298","documentation":"Raised when the OpenAI-compatible chat completion call used for Xiaomi MiMo TTS returns a response that is falsy or has no 'choices' attribute. This means the API call succeeded at the HTTP layer but produced no usable completion object — typically an empty/aborted response or a client that returned an error object instead of raising.","triggerScenarios":"Calling MiMo TTS with a 'mimo:' voice via the chat completions endpoint with audio output; the model returns an empty choices array (content filtered, malformed request, or unsupported audio request); wrong base_url pointing to a non-audio-capable endpoint that returns a minimal completion.","commonSituations":"MIMO_API_KEY/base URL misconfigured so the request hits the wrong model; model name in model_name does not support audio output; upstream content moderation blocked the prompt; SDK version returning a different object shape.","solutions":["Verify the MiMo endpoint and model name are correct and that the model supports audio output (audio: {format: 'wav', voice: ...}).","Check the API key and account quota — auth/limit errors sometimes surface as empty completions depending on client config.","Log the raw completion object when this fires to see what the API actually returned; retry once for transient empties.","Shorten or rephrase style_prompt if content filtering is suspected."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"if not text or not text.strip():\n    raise ValueError(\"MiMo TTS requires non-empty text\")\nif not voice_name or not voice_name.strip():\n    raise ValueError(\"MiMo TTS requires a voice name\")","typeGuard":null,"tryCatchPattern":"try:\n    return azure_tts_v2_mimo(...)  # the MiMo completion call\nexcept ValueError as exc:\n    if \"empty response\" in str(exc):\n        # transient upstream emptiness — one retry, then surface\n        return azure_tts_v2_mimo(...)\n    raise","preventionTips":["Verify the MiMo base URL and model name support audio output before integrating.","Keep the SDK version aligned with the provider's audio-completions API."],"tags":["tts","mimo","api","openai-compatible"],"backgroundTag":null,"analyzedSha":"1f9f19c2021a68d04df228f33e9099a0c947f6f8","analyzedAt":"2026-08-14T19:41:05.568Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}