{"record":{"id":"5f60a714ce5d746e","repo":"chenhg5/cc-connect","slug":"pico2wave-voice-s-text-q-w-output-s","errorCode":null,"errorMessage":"pico2wave: voice=%s text=%q: %w, output: %s","messagePattern":"pico2wave: voice=(.+?) text=%q: %w, output: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/tts.go","lineNumber":640,"sourceCode":"\t}\n\ttmpPath := tmpFile.Name()\n\ttmpFile.Close()\n\tdefer os.Remove(tmpPath)\n\n\t// Build pico2wave command\n\t// --lang: language code (zh-CN for Chinese, en-US for English)\n\t// --wave: output WAV file path\n\targs := []string{\n\t\t\"--lang=\" + voice,\n\t\t\"--wave=\" + tmpPath,\n\t\ttext,\n\t}\n\n\t// Execute pico2wave command\n\tcmd := exec.CommandContext(ctx, p.Path, args...)\n\toutput, err := cmd.CombinedOutput()\n\tif err != nil {\n\t\treturn nil, \"\", fmt.Errorf(\"pico2wave: voice=%s text=%q: %w, output: %s\", voice, text, err, string(output))\n\t}\n\n\t// Read the generated WAV file\n\taudioData, err := os.ReadFile(tmpPath)\n\tif err != nil {\n\t\treturn nil, \"\", fmt.Errorf(\"pico2wave: read output file: %w\", err)\n\t}\n\n\tif len(audioData) == 0 {\n\t\treturn nil, \"\", fmt.Errorf(\"pico2wave: produced empty audio file\")\n\t}\n\n\treturn audioData, \"wav\", nil\n}\n\n// ──────────────────────────────────────────────────────────────\n// EdgeTTS — Microsoft Edge TTS (free, high quality, requires network)\n// ──────────────────────────────────────────────────────────────","sourceCodeStart":622,"sourceCodeEnd":658,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/core/tts.go#L622-L658","documentation":"PicoTTS.Synthesize executes pico2wave --lang=<voice> --wave=<tmpfile> <text> via CombinedOutput; this error is returned when the pico2wave process exits non-zero, wrapping the exec error and including the combined stdout+stderr output for diagnosis. Typical wrapped causes are *exec.ExitError from a bad --lang code or rejected text, or *exec.Error when the pico2wave binary itself cannot be found.","triggerScenarios":"Calling Synthesize via PicoTTS when: pico2wave is not installed or Path is wrong (exec: \"pico2wave\": executable file not found in $PATH); the language code is not among pico2wave's installed voices (stock pico2wave ships only en-US/en-GB/de-DE/es-ES/fr-FR/it-IT — the library's zh-CN default does not exist in stock builds); text contains characters pico2wave rejects; or the context deadline cancels the process.","commonSituations":"Fresh installs of libttspico-utils where the zh-CN default voice doesn't exist; missing SVOX Pico language data files; ARM/non-x86 hosts where pico isn't packaged; Voice configured with an espeak-style code (\"zh+f3\") that pico2wave doesn't understand; empty text argument.","solutions":["Read the 'output:' portion of the error — it contains pico2wave's own message (e.g. 'Unknown language').","Reproduce manually: pico2wave --lang=<voice> --wave=/tmp/t.wav \"<text>\" and inspect stderr.","Verify the language code is one pico2wave supports with installed data (`pico2wave --lang=help` or check /usr/share/pico/lang); replace the zh-CN default with en-US or install a zh voice if your build provides one.","Confirm pico2wave is installed (apt install libttspico-utils) and set PicoTTS.Path to the full binary path if it's not on PATH.","Ensure text is non-empty and free of characters that break argument parsing."],"exampleFix":"// before\npico := core.NewPicoTTS(\"\", \"zh-CN\") // stock pico2wave has no zh-CN\n// after\npico := core.NewPicoTTS(\"\", \"en-US\") // verify with: pico2wave --lang=help\n// or install/configure a pico zh voice package and keep zh-CN","handlingStrategy":"validation","validationCode":"// Go: validate pico2wave and the voice before use\np, err := exec.LookPath(\"pico2wave\")\nif err != nil { /* not installed: apt install libttspico-utils */ }\nvar validVoices = map[string]bool{\n\t\"en-US\": true, \"en-GB\": true, \"de-DE\": true,\n\t\"es-ES\": true, \"fr-FR\": true, \"it-IT\": true,\n}\nif !validVoices[voice] { /* pick a supported voice or install language data */ }","typeGuard":"func picoVoiceSupported(voice string) bool {\n\tswitch voice {\n\tcase \"en-US\", \"en-GB\", \"de-DE\", \"es-ES\", \"fr-FR\", \"it-IT\":\n\t\treturn true\n\t}\n\treturn false\n}","tryCatchPattern":"audio, format, err := pico.Synthesize(ctx, text, opts)\nif err != nil {\n\tvar exitErr *exec.ExitError\n\tif errors.As(err, &exitErr) {\n\t\t// the error message already embeds CombinedOutput; log the full err\n\t\tlog.Printf(\"pico2wave failed: %v\", err)\n\t}\n\t// fallback to espeak or cloud TTS\n\treturn espeak.Synthesize(ctx, text, opts)\n}","preventionTips":["Validate the --lang code against pico2wave's installed voices at config load (stock builds lack zh-CN).","Run `pico2wave --lang=help` or check /usr/share/pico/lang in setup/doctor tooling.","Use exec.LookPath to confirm the binary exists before selecting PicoTTS.","Keep text non-empty and strip control characters before synthesis."],"tags":["tts","pico2wave","exec","external-command","voice"],"backgroundTag":"git-command-failed","analyzedSha":"4000b2338aa6e850c99df54f8b0ed6ed7460b401","analyzedAt":"2026-09-06T11:45:09.575Z","contentChangedAt":"2026-09-06T11:45:09.575Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}