chenhg5/cc-connect · error

edge-tts: voice=%s text=%q: %w, output: %s

Error message

edge-tts: voice=%s text=%q: %w, output: %s

What it means

EdgeTTS.Synthesize (core/tts.go:709) executes the external edge-tts CLI with --voice/--text/--write-media and captures its combined output. This error is returned when the CLI exits non-zero; it wraps the exec error (including context cancellation/timeout) and includes the voice, text, and the CLI's stderr/stdout for diagnosis. Since edge-tts calls Microsoft's network service, most failures are network or service-side.

Source

Thrown at core/tts.go:709

	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...)
	output, err := cmd.CombinedOutput()
	if err != nil {
		return nil, "", fmt.Errorf("edge-tts: voice=%s text=%q: %w, output: %s", voice, text, err, string(output))
	}

	// Read the generated MP3 file
	audioData, err := os.ReadFile(tmpPath)
	if err != nil {
		return nil, "", fmt.Errorf("edge-tts: read output file: %w", err)
	}

	if len(audioData) == 0 {
		return nil, "", fmt.Errorf("edge-tts: produced empty audio file")
	}

	return audioData, "mp3", nil
}

View on GitHub (pinned to 4000b2338a)

Solutions

  1. Read the 'output:' portion of the error to see the underlying CLI message; fix accordingly (missing binary, auth, network)
  2. Install/upgrade edge-tts (`pip install -U edge-tts`) — outdated versions break when Microsoft rotates service tokens and return 403
  3. Verify network access to Microsoft's speech endpoints (speech.platform.bing.com); check proxy/firewall and set HTTPS_PROXY if needed
  4. Confirm the configured voice name is valid: `edge-tts --list-voices | grep Xiaoxiao`
  5. Retry on transient network errors; check that ctx timeouts are not expiring prematurely

Example fix

// before
EdgeTTS: { Voice: "zh-CN-XiaoXiao" } // invalid voice name
// after
EdgeTTS: { Voice: "zh-CN-XiaoxiaoNeural" } // valid name from `edge-tts --list-voices`
Defensive patterns

Strategy: try-catch

Validate before calling

if _, err := exec.LookPath("edge-tts"); err != nil {
    return errors.New("edge-tts CLI not found on PATH; install with: pip install edge-tts")
}
if strings.TrimSpace(text) == "" {
    return errors.New("empty text for TTS")
}

Try / catch

audio, format, err := edge.Synthesize(ctx, text, opts)
if err != nil {
    var ctxErr error
    if errors.Is(ctx.Err(), context.DeadlineExceeded) || strings.Contains(err.Error(), "context") {
        return fmt.Errorf("edge-tts timed out: %w", err)
    }
    if strings.Contains(err.Error(), "403") || strings.Contains(err.Error(), "Exception") {
        return fmt.Errorf("edge-tts service rejected request (upgrade edge-tts): %w", err)
    }
    return fmt.Errorf("edge-tts failed: %w", err)
}

Prevention

When it happens

Trigger: Calling EdgeTTS.Synthesize when the edge-tts binary cannot run or fails: binary not found on PATH, no network connectivity or Microsoft's Edge TTS endpoint unreachable/blocked, edge-tts token/service error (403s from expired client tokens on outdated edge-tts versions), an invalid --voice name, context deadline exceeded during synthesis, or a Python edge-tts install that is broken.

Common situations: Developers hit this in air-gapped or firewalled environments, after Microsoft changes its TTS auth so old pip-installed edge-tts versions get EdgeTTSException/403, when the voice string is misspelled (e.g. 'zh-CN-Xiaoxiao' instead of 'zh-CN-XiaoxiaoNeural'), or when the CLI simply isn't installed (`command not found`).

Understand the failure class

Background: "API error: {status}" and "HTTP 401/403/404/429/5xx" errors: non-2xx HTTP responses explained — this error's family across 27 libraries.

Related errors


AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06). Data as JSON: /api/errors/f757c4c4de735cb5. Report an issue: GitHub.