mudler/LocalAI · error

[moss-tts-cpp] ERROR: text is required\n

Error message

[moss-tts-cpp] ERROR: text is required\n

What it means

mtl_tts() rejects the call because text is NULL or empty (model already loaded at this point). Returns nullptr. Synthesis of an empty prompt is meaningless, so the shim refuses before invoking moss_local_tts.

Source

Thrown at backend/go/moss-tts-cpp/cpp/mossttscpp.cpp:71

        fprintf(stderr, "[moss-tts-cpp] FATAL: moss_local_load failed\n");
        return 4;
    }
    fprintf(stderr, "[moss-tts-cpp] Model loaded (%s)\n", moss_tts_version());
    return 0;
}

float *mtl_tts(const char *text, const char *reference_wav, int seed,
               int *out_n, int *out_sr) {
    if (out_n)
        *out_n = 0;
    if (out_sr)
        *out_sr = 0;
    if (!g_local) {
        fprintf(stderr, "[moss-tts-cpp] ERROR: model not loaded\n");
        return nullptr;
    }
    if (!text || text[0] == '\0') {
        fprintf(stderr, "[moss-tts-cpp] ERROR: text is required\n");
        return nullptr;
    }

    // An empty reference path means "no cloning": pass NULL so the engine skips
    // the clone branch rather than trying to open "".
    const char *ref = (reference_wav && reference_wav[0] != '\0')
                          ? reference_wav
                          : nullptr;

    int n = 0, sr = 0;
    float *pcm = moss_local_tts(g_local, text, ref, seed, &n, &sr);
    if (!pcm || n <= 0) {
        fprintf(stderr, "[moss-tts-cpp] ERROR: moss_local_tts failed\n");
        if (pcm)
            moss_free(pcm);
        return nullptr;
    }

View on GitHub (pinned to 44413a9d06)

Solutions

  1. Validate the request text is non-empty before calling the backend.
  2. Return a 400-style error to the API client instead of attempting synthesis.

Example fix

// before
if req.Input == nil { req.Input = &[]string{}[0] }
// after
if strings.TrimSpace(text) == "" {
    return errors.New("tts: input text is required")
}
Defensive patterns

Strategy: validation

Validate before calling

if strings.TrimSpace(text) == "" {
    return nil, errors.New("tts: input text is required")
}

Prevention

When it happens

Trigger: Calling mtl_tts("", ref, seed, ...) — e.g., an API request with an absent/blank input field serialized to an empty C string.

Common situations: OpenAI-compatible TTS request with missing "input" field; upstream text-extraction produced empty string after sanitization.

Related errors


AI-assisted analysis of mudler/LocalAI@44413a9d06 (2026-08-15). Data as JSON: /api/errors/f57977c15d94b447. Report an issue: GitHub.