chenhg5/cc-connect · error
edge-tts: create temp file: %w
Error message
edge-tts: create temp file: %w
What it means
EdgeTTS.Synthesize (core/tts.go:688) first creates a secure temp file via os.CreateTemp to hold the MP3 that the edge-tts CLI will write. This error wraps any failure of that temp-file creation with the 'edge-tts: create temp file:' prefix. It almost always reflects an OS-level problem with the temp directory, not with edge-tts itself.
Source
Thrown at core/tts.go:688
voice = "zh-CN-XiaoxiaoNeural" // default Chinese voice
}
return &EdgeTTS{
Voice: voice,
}
}
// Synthesize uses edge-tts CLI to convert text to MP3 audio bytes.
// EdgeTTS provides high-quality neural voices but requires network connection.
func (e *EdgeTTS) Synthesize(ctx context.Context, text string, opts TTSSynthesisOpts) ([]byte, string, error) {
voice := opts.Voice
if voice == "" {
voice = e.Voice
}
// Create secure temp file for edge-tts output
tmpFile, err := os.CreateTemp("", "edge_tts_*.mp3")
if err != nil {
return nil, "", fmt.Errorf("edge-tts: create temp file: %w", err)
}
tmpPath := tmpFile.Name()
tmpFile.Close()
defer os.Remove(tmpPath)
// Use edge-tts CLI directly to avoid code injection risks
// Pass text via --text argument, not via embedded code
args := []string{
"--voice", voice,
"--text", text,
"--write-media", tmpPath,
}
path := e.Path
if path == "" {
path = "edge-tts"
}
cmd := exec.CommandContext(ctx, path, args...)View on GitHub (pinned to 4000b2338a)
Solutions
- Check disk space on the temp filesystem (`df -h /tmp` or `$TMPDIR`) and free space if full
- Verify TMPDIR/TMP/TMP_DIR env vars point to an existing, writable directory; fix or unset them
- If running in a container/sandbox, make the temp directory writable or set TMPDIR to a writable volume mount
- Check process permissions/SELinux policies blocking writes to the temp directory
Example fix
// before
os.Setenv("TMPDIR", "/read-only/dir")
audio, format, err := edgeTTS.Synthesize(ctx, text, opts)
// after
os.MkdirAll("/var/tmp/cc-connect", 0o755)
os.Setenv("TMPDIR", "/var/tmp/cc-connect")
audio, format, err := edgeTTS.Synthesize(ctx, text, opts) Defensive patterns
Strategy: try-catch
Validate before calling
tmpDir := os.TempDir()
if fi, err := os.Stat(tmpDir); err != nil || !fi.IsDir() {
return fmt.Errorf("temp dir %s unusable: %w", tmpDir, err)
}
probe, err := os.CreateTemp(tmpDir, "tts_probe_*")
if err != nil {
return fmt.Errorf("temp dir not writable: %w", err)
}
probe.Close(); os.Remove(probe.Name()) Try / catch
audio, format, err := edge.Synthesize(ctx, text, opts)
if err != nil {
var pathErr *os.PathError
if errors.As(err, &pathErr) && strings.Contains(err.Error(), "create temp file") {
return fmt.Errorf("tts unavailable: check TMPDIR/disk space: %w", err)
}
return err
} Prevention
- Ensure TMPDIR points to an existing writable directory in containers and daemons
- Monitor disk space on the temp filesystem and alert before it fills
- Avoid read-only root filesystems without a writable tmp mount for processes doing TTS
- Test TTS startup under systemd PrivateTmp/sandbox profiles during deployment
When it happens
Trigger: Calling EdgeTTS.Synthesize when os.CreateTemp("", "edge_tts_*.mp3") fails — TMPDIR/TMP points to a non-existent or read-only directory, the filesystem is full (no space left on device), or the process lacks write permission on /tmp or the configured temp dir.
Common situations: Containerized deployments with a read-only root filesystem or a TMPDIR mounted read-only, disk-quota exhaustion on long-running daemons, sandboxed environments (e.g. systemd PrivateTmp misconfig, hardened sandboxes) that deny writes to the default temp directory.
Understand the failure class
Background: "open() failed", "failed to open file", "cannot create file" — what a file open error means and how to fix it — this error's family across 42 libraries.
Related errors
- edge-tts: read output file: %w
- pico2wave: create temp file: %w
- claudeSession: write per-spawn prompt file: %w
- pico2wave: read output file: %w
- edge-tts: voice=%s text=%q: %w, output: %s
AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06).
Data as JSON: /api/errors/888190c537c60a29.
Report an issue: GitHub.