From c2ff2e8b17f5dd0460aa020aaa21deb59d7fe15f Mon Sep 17 00:00:00 2001 From: kshitij <82637225+kshitijk4poor@users.noreply.github.com> Date: Sun, 2 Aug 2026 23:17:21 +0530 Subject: [PATCH] polish(discord): surface ffmpeg stderr on pcm_to_wav failure Simplify-pass follow-up on the #68157 salvage (regression-neutral \u2014 the old temp-file version was equally bare): capture ffmpeg's -loglevel error output so a CalledProcessError carries the real message, and log it at the voice-input catch site. Parity with transcription_tools' ffmpeg call sites. Live-verified: forced ffmpeg failure produces the captured message in the exception. --- plugins/platforms/discord/adapter.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/plugins/platforms/discord/adapter.py b/plugins/platforms/discord/adapter.py index 4033feca90..99e0f9a2f5 100644 --- a/plugins/platforms/discord/adapter.py +++ b/plugins/platforms/discord/adapter.py @@ -862,6 +862,11 @@ class VoiceReceiver: input=pcm_data, check=True, timeout=10, + # Capture ffmpeg's -loglevel error output so a failure's + # CalledProcessError carries the actual message (parity with + # tools/transcription_tools' ffmpeg call sites) instead of + # "returned non-zero exit status N" with stderr detached. + stderr=subprocess.PIPE, creationflags=windows_hide_flags(), ) @@ -4479,7 +4484,18 @@ class DiscordAdapter(BasePlatformAdapter): transcript=transcript, ) except Exception as e: - logger.warning("Voice input processing failed: %s", e, exc_info=True) + # CalledProcessError from pcm_to_wav carries ffmpeg's captured + # stderr — surface it, or the log only says "exit status N". + _ff_err = getattr(e, "stderr", None) + if _ff_err: + if isinstance(_ff_err, bytes): + _ff_err = _ff_err.decode("utf-8", "replace") + logger.warning( + "Voice input processing failed: %s (ffmpeg: %s)", + e, _ff_err.strip(), exc_info=True, + ) + else: + logger.warning("Voice input processing failed: %s", e, exc_info=True) finally: try: os.unlink(wav_path)