mudler/LocalAI · error
audio too large for 32-bit WAV (%PRIu64 bytes)\n
Error message
audio too large for 32-bit WAV (%PRIu64 bytes)\n
What it means
The generated audio exceeds the 4 GiB limit of 32-bit WAV. Guard: estimate samples*channels*bytes before encoding and either chunk the output or reject requests that exceed the WAV limit.
Source
Thrown at backend/go/stablediffusion-ggml/cpp/gosd.cpp:1165
// Returns 0 on success and fills wav_path (must be at least 64 bytes).
static int write_planar_float_wav(const sd_audio_t* a, char* wav_path, size_t wav_path_sz) {
if (!a || !a->data || a->sample_count == 0 || a->channels == 0 || a->sample_rate == 0) {
return -1;
}
snprintf(wav_path, wav_path_sz, "/tmp/gosd-audio-XXXXXX.wav");
int fd = mkstemps(wav_path, 4);
if (fd < 0) { perror("mkstemps wav"); return -1; }
FILE* f = fdopen(fd, "wb");
if (!f) { perror("fdopen wav"); close(fd); return -1; }
uint64_t frames = a->sample_count;
uint32_t channels = a->channels;
uint32_t sample_rate = a->sample_rate;
uint64_t total_samples64 = frames * (uint64_t)channels;
uint64_t data_bytes64 = total_samples64 * sizeof(float);
if (data_bytes64 > 0xFFFFFFFFull - 44) {
fprintf(stderr, "audio too large for 32-bit WAV (%" PRIu64 " bytes)\n", data_bytes64);
fclose(f);
unlink(wav_path);
return -1;
}
uint32_t data_bytes = (uint32_t)data_bytes64;
uint32_t riff_size = 36 + data_bytes;
uint16_t fmt_code = 3; // WAVE_FORMAT_IEEE_FLOAT
uint16_t bits_per_sample = 32;
uint16_t block_align = (uint16_t)(channels * sizeof(float));
uint32_t byte_rate = sample_rate * block_align;
uint16_t ch16 = (uint16_t)channels;
uint32_t fmt_size = 16;
fwrite("RIFF", 1, 4, f);
fwrite(&riff_size, 4, 1, f);
fwrite("WAVEfmt ", 1, 8, f);
fwrite(&fmt_size, 4, 1, f);
fwrite(&fmt_code, 2, 1, f);View on GitHub (pinned to 44413a9d06)
Solutions
- Shorten the generated audio so the WAV stays under the 4 GiB 32-bit limit.
- Split the output into multiple WAV files or use a 64-bit-capable format.
When it happens
Trigger: Thrown at backend/go/stablediffusion-ggml/cpp/gosd.cpp:1165 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/cac4c47e3ed34b54.
Report an issue: GitHub.