harry0703/MoneyPrinterTurbo · error · ValueError

MiMo TTS returned empty response

Error message

MiMo TTS returned empty response

What it means

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.

Source

Thrown at app/services/voice.py:1280

                f"start mimo tts, model: {model_name}, voice: {voice_name}, try: {i + 1}"
            )
            ensure_file_path_exists(voice_file)

            client = OpenAI(api_key=api_key, base_url=base_url)
            completion = client.chat.completions.create(
                model=model_name,
                messages=[
                    {"role": "user", "content": style_prompt},
                    {"role": "assistant", "content": text},
                ],
                audio={
                    "format": "wav",
                    "voice": voice_name,
                },
            )

            if not completion or not getattr(completion, "choices", None):
                raise ValueError("MiMo TTS returned empty response")

            message = completion.choices[0].message
            audio = getattr(message, "audio", None)
            audio_data = None
            if isinstance(audio, dict):
                audio_data = audio.get("data")
            elif audio is not None:
                audio_data = getattr(audio, "data", None)

            if not audio_data:
                raise ValueError("MiMo TTS returned empty audio data")

            audio_bytes = base64.b64decode(audio_data)
            audio_segment = AudioSegment.from_file(io.BytesIO(audio_bytes), format="wav")

            output_format = utils.parse_extension(voice_file) or "mp3"
            if output_format == "wav":
                with open(voice_file, "wb") as f:

View on GitHub (pinned to 1f9f19c202)

Solutions

  1. Verify the MiMo endpoint and model name are correct and that the model supports audio output (audio: {format: 'wav', voice: ...}).
  2. Check the API key and account quota — auth/limit errors sometimes surface as empty completions depending on client config.
  3. Log the raw completion object when this fires to see what the API actually returned; retry once for transient empties.
  4. Shorten or rephrase style_prompt if content filtering is suspected.
Defensive patterns

Strategy: retry

Validate before calling

if not text or not text.strip():
    raise ValueError("MiMo TTS requires non-empty text")
if not voice_name or not voice_name.strip():
    raise ValueError("MiMo TTS requires a voice name")

Try / catch

try:
    return azure_tts_v2_mimo(...)  # the MiMo completion call
except ValueError as exc:
    if "empty response" in str(exc):
        # transient upstream emptiness — one retry, then surface
        return azure_tts_v2_mimo(...)
    raise

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of harry0703/MoneyPrinterTurbo@1f9f19c202 (2026-08-14). Data as JSON: /api/errors/77b96ccb7f353bce. Report an issue: GitHub.