mudler/LocalAI · error
[acestep-cpp] ERROR: failed to write %s\n
Error message
[acestep-cpp] ERROR: failed to write %s\n
What it means
audio_write_wav() returned false when writing the normalized stereo PCM to the destination WAV path at 48 kHz. This is an I/O-level failure at the very last step (exit code 7): the generation itself succeeded, only persisting the file failed. Causes are typically an unwritable directory, a full disk, or a path encoding/permission problem.
Source
Thrown at backend/go/acestep-cpp/cpp/goacestepcpp.cpp:295
int n_samples = 2 * T_audio;
for (int i = 0; i < n_samples; i++) {
float a = audio[i] < 0 ? -audio[i] : audio[i];
if (a > peak) {
peak = a;
}
}
if (peak > 1e-6f) {
const float target_amp = powf(10.0f, -1.0f / 20.0f);
float gain = target_amp / peak;
for (int i = 0; i < n_samples; i++) {
audio[i] *= gain;
}
}
}
// 13. Write WAV output
if (!audio_write_wav(dst, audio.data(), T_audio, 48000)) {
fprintf(stderr, "[acestep-cpp] ERROR: failed to write %s\n", dst);
return 7;
}
fprintf(stderr, "[acestep-cpp] Wrote %s: %d samples (%.2fs @ 48kHz stereo)\n",
dst, T_audio, (float)T_audio / 48000.0f);
return 0;
}
View on GitHub (pinned to 44413a9d06)
Solutions
- Check that the parent directory of dst exists and is writable (mkdir -p it before generating).
- Verify free disk space — the WAV is uncompressed stereo PCM at 48 kHz.
- Run the write path manually (touch the exact dst) to surface permission errors, and inspect errno-level messages on stderr.
- If running in a container, confirm the output volume is mounted read-write.
Example fix
// before
snprintf(dst, sizeof dst, "/tmp/out/%s.wav", name);
// after: ensure the directory exists before generating
mkdir("/tmp/out", 0755);
snprintf(dst, sizeof dst, "/tmp/out/%s.wav", name); Defensive patterns
Strategy: validation
Validate before calling
if dir := filepath.Dir(dst); dir != "" {
if err := os.MkdirAll(dir, 0o755); err != nil {
return fmt.Errorf("output dir: %w", err)
}
}
if err := unix.Access(dir, unix.W_OK); err != nil {
return fmt.Errorf("output dir not writable: %w", err)
} Prevention
- Create and probe-writable the output directory before an expensive generation run.
- Check free disk space proportional to duration (48 kHz stereo PCM ≈ 384 KB/s).
- Surface the dst path in errors so users see which path failed.
When it happens
Trigger: Calling generate with a dst path whose parent directory does not exist or is not writable, a read-only filesystem or container mount, or disk exhaustion (48 kHz stereo floats are heavy — minutes of audio are tens of MB).
Common situations: Output dir not created before the call in a scratch/container environment; running under a user without write permission to the model/output folder; disk-full after large model downloads consumed space; dst containing characters the platform rejects.
Related errors
- ds4 KvCache::Save: fopen failed: %s
- [acestep-cpp] FATAL: failed to load text encoder\n
- [acestep-cpp] FATAL: failed to load condition encoder\n
- [acestep-cpp] ERROR: VAE decode failed\n
- Embedding directory does not exist or is not a directory: %s
AI-assisted analysis of mudler/LocalAI@44413a9d06 (2026-08-15).
Data as JSON: /api/errors/9be70e1a95bd435d.
Report an issue: GitHub.