Skip to content

Commit 2a42b97

Browse files
metiu1claude
andcommitted
Fix Whisper transcription: surface real errors + keep stdout clean
- Transcription errors now include the Python stderr (missing ffmpeg, package/model issues) instead of a bare 'exit status 1'. - The 'Loading: <model>' status line now goes to stderr, so stdout is the pure transcript (was leaking the status text as the result on short/silent clips). Verified end-to-end: a test WAV transcribes with clean output. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent ce8e202 commit 2a42b97

1 file changed

Lines changed: 17 additions & 2 deletions

File tree

vortelio/internal/runtime/audio_runner.go

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ func (r *AudioRunner) buildWhisperScript(opts *RunOptions) string {
293293
``,
294294
`if _lib == "faster-whisper":`,
295295
` _ct = "float16" if _dev == "cuda" else "int8"`,
296-
` print("Loading: " + _fw_model + " (" + _ct + ")")`,
296+
` print("Loading: " + _fw_model + " (" + _ct + ")", file=sys.stderr)`,
297297
` _m = _FW(_fw_model, device=_dev, compute_type=_ct)`,
298298
` _segs, _ = _m.transcribe("""` + inputPath + `""", beam_size=5)`,
299299
` _text = "".join(seg.text for seg in _segs)`,
@@ -334,7 +334,22 @@ func (r *AudioRunner) TranscribeText(inputFile string) (string, error) {
334334
cmd.Env = append(os.Environ(), "PYTHONIOENCODING=utf-8", "PYTHONUTF8=1")
335335
out, err := cmd.Output()
336336
if err != nil {
337-
return "", fmt.Errorf("transcription failed: %w", err)
337+
// Surface the Python stderr so the real cause is visible (missing ffmpeg,
338+
// package not installed, model download failure, …) instead of "exit 1".
339+
detail := ""
340+
if ee, ok := err.(*exec.ExitError); ok {
341+
detail = strings.TrimSpace(string(ee.Stderr))
342+
}
343+
if detail == "" {
344+
detail = strings.TrimSpace(string(out))
345+
}
346+
if detail == "" {
347+
detail = err.Error()
348+
}
349+
if len(detail) > 500 {
350+
detail = "…" + detail[len(detail)-500:]
351+
}
352+
return "", fmt.Errorf("transcription failed: %s", detail)
338353
}
339354
lines := strings.Split(strings.TrimSpace(string(out)), "\n")
340355
// The last non-empty line is the transcribed text

0 commit comments

Comments
 (0)