mudler/LocalAI · error

[omnivoice-cpp] ERROR: malloc(%zu) failed\n

Error message

[omnivoice-cpp] ERROR: malloc(%zu) failed\n

What it means

Memory allocation for the output PCM buffer failed. Guard: cap the maximum synthesis length/sample count before allocating, and return a resource-exhausted error to the caller rather than aborting the worker.

Source

Thrown at backend/go/omnivoice-cpp/cpp/gomnivoicecpp.cpp:113

    ov_tts_params tp;
    fill_params(&tp, text, lang, instruct, ref_samples, ref_n, ref_text, seed,
                denoise);

    ov_audio out = {0};
    enum ov_status rc = ov_synthesize(g_ctx, &tp, &out);
    if (rc != OV_STATUS_OK || out.n_samples <= 0 || !out.samples) {
        fprintf(stderr, "[omnivoice-cpp] ERROR: synthesize failed (rc=%d): %s\n",
                (int)rc, ov_last_error());
        ov_audio_free(&out);
        return nullptr;
    }

    // Copy into a plain malloc buffer the Go side can free symmetrically via
    // omni_pcm_free; then release the ov_audio-owned buffer.
    size_t bytes = (size_t)out.n_samples * sizeof(float);
    float *buf = (float *)malloc(bytes);
    if (!buf) {
        fprintf(stderr, "[omnivoice-cpp] ERROR: malloc(%zu) failed\n", bytes);
        ov_audio_free(&out);
        return nullptr;
    }
    memcpy(buf, out.samples, bytes);
    if (out_n)
        *out_n = out.n_samples;
    ov_audio_free(&out);
    return buf;
}

int omni_tts_stream(const char *text, const char *lang, const char *instruct,
                    const float *ref_samples, int ref_n, const char *ref_text,
                    long long seed, int denoise, omni_pcm_chunk_cb cb,
                    void *user_data) {
    if (!g_ctx) {
        fprintf(stderr, "[omnivoice-cpp] ERROR: model not loaded\n");
        return 1;
    }

View on GitHub (pinned to 44413a9d06)

Solutions

  1. Reduce the requested audio/text size so the output buffer fits in available memory.
  2. Free system memory or increase available RAM/swap; check for memory leaks in long-running processes.

When it happens

Trigger: Thrown at backend/go/omnivoice-cpp/cpp/gomnivoicecpp.cpp:113 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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