The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
refactor(discord): delegate ffmpeg discovery to shared tools.transcription_tools helper
Tekniuma4c999483792
diff --git a/plugins/platforms/discord/ffmpeg_utils.py b/plugins/platforms/discord/ffmpeg_utils.pyindex 6e5ef844540..d1fdbdc98de 100644--- a/plugins/platforms/discord/ffmpeg_utils.py+++ b/plugins/platforms/discord/ffmpeg_utils.py@@ -1,4 +1,11 @@-"""Shared ffmpeg executable discovery for Discord voice paths."""+"""Shared ffmpeg executable discovery for Discord voice paths.++Discovery itself is owned by ``tools.transcription_tools`` (the same helper+the STT pipeline uses — PATH plus common Homebrew/local prefixes); this module+only layers the Discord-voice-specific extras on top: an explicit+``FFMPEG_PATH`` override and a Windows winget fallback for installs that+never touch PATH.+"""from __future__ import annotations@@ -7,13 +14,22 @@ import shutilfrom pathlib import Path+def _shared_find_ffmpeg():+ """Delegate to the repo-wide ffmpeg discovery helper when importable."""+ try:+ from tools.transcription_tools import _find_ffmpeg_binary+ except ImportError: # standalone plugin import (tests / sandboxes)+ return shutil.which("ffmpeg")+ return _find_ffmpeg_binary()++def resolve_ffmpeg_executable() -> str:"""Return an ffmpeg command that also covers common Windows installs."""explicit = os.getenv("FFMPEG_PATH")if explicit and explicit.strip():return os.path.expandvars(os.path.expanduser(explicit.strip()))- discovered = shutil.which("ffmpeg")+ discovered = _shared_find_ffmpeg()if discovered:return discovereddiff --git a/tests/gateway/test_voice_command.py b/tests/gateway/test_voice_command.pyindex cf27b238553..7fc4a3bc3b4 100644--- a/tests/gateway/test_voice_command.py+++ b/tests/gateway/test_voice_command.py@@ -757,10 +757,22 @@ class TestVoiceReceiver:monkeypatch.delenv("FFMPEG_PATH", raising=False)monkeypatch.setenv("LOCALAPPDATA", str(tmp_path))- monkeypatch.setattr(ffmpeg_utils.shutil, "which", lambda _cmd: None)+ # Discovery delegates to tools.transcription_tools; simulate "not found".+ monkeypatch.setattr(ffmpeg_utils, "_shared_find_ffmpeg", lambda: None)assert ffmpeg_utils.resolve_ffmpeg_executable() == str(ffmpeg)+ def test_ffmpeg_resolver_delegates_to_shared_helper(self, monkeypatch):+ """PATH/local-prefix discovery is owned by tools.transcription_tools."""+ from plugins.platforms.discord import ffmpeg_utils++ monkeypatch.delenv("FFMPEG_PATH", raising=False)+ monkeypatch.setattr(+ "tools.transcription_tools._find_ffmpeg_binary", lambda: "/opt/homebrew/bin/ffmpeg"+ )++ assert ffmpeg_utils.resolve_ffmpeg_executable() == "/opt/homebrew/bin/ffmpeg"+def test_pcm_to_wav_uses_resolved_ffmpeg_executable(self, monkeypatch, tmp_path):"""Receiver conversion should use the same resolved executable as playback."""from plugins.platforms.discord import adapter as discord_adapter