chenhg5/cc-connect · error
pico2wave: produced empty audio file
Error message
pico2wave: produced empty audio file
What it means
PicoTTS.Synthesize (core/tts.go:650) runs the external pico2wave CLI to synthesize text into a WAV temp file, then reads it back. This error is returned when pico2wave exits successfully (exit code 0) but wrote a zero-byte WAV file, meaning no audio was actually produced. The library treats a silent/empty output as a synthesis failure rather than returning empty audio to the caller.
Source
Thrown at core/tts.go:650
"--wave=" + tmpPath,
text,
}
// Execute pico2wave command
cmd := exec.CommandContext(ctx, p.Path, args...)
output, err := cmd.CombinedOutput()
if err != nil {
return nil, "", fmt.Errorf("pico2wave: voice=%s text=%q: %w, output: %s", voice, text, err, string(output))
}
// Read the generated WAV file
audioData, err := os.ReadFile(tmpPath)
if err != nil {
return nil, "", fmt.Errorf("pico2wave: read output file: %w", err)
}
if len(audioData) == 0 {
return nil, "", fmt.Errorf("pico2wave: produced empty audio file")
}
return audioData, "wav", nil
}
// ──────────────────────────────────────────────────────────────
// EdgeTTS — Microsoft Edge TTS (free, high quality, requires network)
// ──────────────────────────────────────────────────────────────
// EdgeTTS implements TextToSpeech using Microsoft Edge's free TTS API.
// This uses the edge-tts CLI command under the hood.
type EdgeTTS struct {
Path string // path to edge-tts executable (empty = "edge-tts")
Voice string // default voice (e.g. "zh-CN-XiaoxiaoNeural")
}
// NewEdgeTTS creates a new EdgeTTS instance.
func NewEdgeTTS(voice string) *EdgeTTS {View on GitHub (pinned to 4000b2338a)
Solutions
- Check the text argument passed to Synthesize is non-empty and contains pronounceable characters before calling
- Verify pico2wave has the voice/language packs for the configured --lang (run `pico2wave --lang=en-US -w /tmp/t.wav 'test'` manually and inspect the file size)
- Reinstall/symlink the missing libttspico language data files (e.g. /usr/share/pico/lang/*)
- Fall back to another TTS backend (espeak, edge-tts) when this error occurs
Example fix
// before
audio, format, err := tts.Synthesize(ctx, strings.TrimSpace(userText), opts)
// after
text := strings.TrimSpace(userText)
if text == "" {
return fmt.Errorf("cannot synthesize empty text")
}
audio, format, err := tts.Synthesize(ctx, text, opts) Defensive patterns
Strategy: validation
Validate before calling
func canSynthesize(tts *core.PicoTTS, text string) error {
if strings.TrimSpace(text) == "" {
return errors.New("empty text for TTS")
}
return nil
} Type guard
if len(audio) == 0 || (len(audio) > 44 && string(audio[:4]) != "RIFF") {
// treat as failed synthesis, use fallback TTS
} Try / catch
audio, format, err := pico.Synthesize(ctx, text, opts)
if err != nil {
if strings.Contains(err.Error(), "produced empty audio file") {
slog.Warn("pico2wave produced no audio, falling back to espeak")
audio, format, err = espeak.Synthesize(ctx, text, opts)
}
if err != nil {
return fmt.Errorf("tts: %w", err)
}
} Prevention
- Trim and validate text before passing it to Synthesize
- Verify the pico2wave language packs are installed for every --lang you configure
- Add a CI/doctor check that synthesizes a test string and asserts non-empty WAV output
- Keep a fallback TTS backend for environments with incomplete voice packs
When it happens
Trigger: Calling PicoTTS.Synthesize (directly or via the TTS engine) when the pico2wave binary exits 0 but creates no WAV content — e.g. synthesizing empty or whitespace-only text, an unsupported --lang value that pico2wave silently ignores, text consisting only of characters pico cannot pronounce, or a pico2wave build missing the language voice packs writing nothing while still exiting 0.
Common situations: Developers hit this on minimal/container images where libttspico language data is partially installed, after passing an invalid voice like 'zh-CN' on a build with only en-US packs, or when downstream code (e.g. message preprocessing) trims the text to an empty string before synthesis.
Understand the failure class
Background: "empty response", "returned no data", "empty embeddings": what HTTP 200-with-empty-body errors mean across libraries — this error's family across 36 libraries.
Related errors
- edge-tts: produced empty audio file
- pico2wave: create temp file: %w
- pico2wave: voice=%s text=%q: %w, output: %s
- 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/c09f9e3f3cb4f54b.
Report an issue: GitHub.