fix(gateway): make Telegram auto-TTS provider-aware - #62040
Conversation
3ae1956 to
1b4a0d5
Compare
teknium1
left a comment
There was a problem hiding this comment.
Thanks for covering both gateway auto-TTS paths and preserving command/plugin-provider behavior. The main direction addresses a current Telegram delivery bug.
Problems
tools/tts_tool.py:401classifies Gemini as native Opus, but_generate_gemini_ttsproduces PCM/WAV and needs ffmpeg to encode a valid.ogg/Opus file (tools/tts_tool.py:1768-1810). Without ffmpeg it copies WAV bytes to the.oggpath, while the new routing later marks that path voice-compatible (tools/tts_tool.py:2467-2468). The new Gemini test stubs the generator with OGG bytes, so it does not cover the real codec path.
Suggested changes
- Separate Gemini from native-Opus providers or explicitly model its ffmpeg dependency, and add a regression covering the no-ffmpeg/resulting-codec behavior before advertising a Telegram voice bubble.
Automated hermes-sweeper review.
| "kittentts", | ||
| "piper", | ||
| }) | ||
| NATIVE_OPUS_TTS_PROVIDERS = frozenset({"elevenlabs", "openai", "mistral", "gemini"}) |
There was a problem hiding this comment.
Gemini is not native Opus: _generate_gemini_tts receives raw PCM, wraps it as WAV, then uses ffmpeg for .ogg/Opus; without ffmpeg it copies WAV bytes to the .ogg path. Please model that dependency separately and add a regression for the no-ffmpeg path rather than treating Gemini as a native-Opus provider.
…bbles Salvaged from PR #62040 (@giladbau), simplified per post-#73072 main: the central _repair_ogg_container transcode makes an explicit .ogg output path sufficient — no target_platform plumbing through the TTS tool needed. Root cause (class-level): both gateway auto-TTS delivery call sites relied on the TTS tool reading HERMES_SESSION_PLATFORM to pick Ogg/Opus vs MP3, but that contextvar is cleared by _clear_session_env before the base adapter's post-handler auto-TTS block runs, so want_opus was always False on that path → MP3 → Telegram sent an audio attachment instead of a native voice bubble (#57049, #36685). The runner's _send_voice_reply had the sibling bug: it hardcoded .ogg for Telegram only, leaving Matrix and Feishu runner voice replies as MP3 (#14841, #45557). Fix: new build_auto_tts_output_path(platform) in gateway/platforms/base.py hands an explicit .ogg temp path when the platform is in the TTS tool's OPUS_VOICE_PLATFORMS set (single source of truth — telegram/matrix/feishu/ whatsapp/signal), .mp3 otherwise. Used by BOTH delivery call sites: - BasePlatformAdapter auto-TTS block (also honors the tool's success flag and cleans up requested + returned paths) - GatewayRunner._send_voice_reply (replaces the telegram-only ternary) Fixes #57049 Fixes #36685 Refs #14841 #45557
…bbles Salvaged from PR #62040 (@giladbau), simplified per post-#73072 main: the central _repair_ogg_container transcode makes an explicit .ogg output path sufficient — no target_platform plumbing through the TTS tool needed. Root cause (class-level): both gateway auto-TTS delivery call sites relied on the TTS tool reading HERMES_SESSION_PLATFORM to pick Ogg/Opus vs MP3, but that contextvar is cleared by _clear_session_env before the base adapter's post-handler auto-TTS block runs, so want_opus was always False on that path → MP3 → Telegram sent an audio attachment instead of a native voice bubble (#57049, #36685). The runner's _send_voice_reply had the sibling bug: it hardcoded .ogg for Telegram only, leaving Matrix and Feishu runner voice replies as MP3 (#14841, #45557). Fix: new build_auto_tts_output_path(platform) in gateway/platforms/base.py hands an explicit .ogg temp path when the platform is in the TTS tool's OPUS_VOICE_PLATFORMS set (single source of truth — telegram/matrix/feishu/ whatsapp/signal), .mp3 otherwise. Used by BOTH delivery call sites: - BasePlatformAdapter auto-TTS block (also honors the tool's success flag and cleans up requested + returned paths) - GatewayRunner._send_voice_reply (replaces the telegram-only ternary) Fixes #57049 Fixes #36685 Refs #14841 #45557
|
Merged into main via consolidated salvage PR #73508 (merge Your contribution is credited to you in git history. Thank you! Closing this PR as merged-via-salvage. |
…bbles Salvaged from PR NousResearch#62040 (@giladbau), simplified per post-NousResearch#73072 main: the central _repair_ogg_container transcode makes an explicit .ogg output path sufficient — no target_platform plumbing through the TTS tool needed. Root cause (class-level): both gateway auto-TTS delivery call sites relied on the TTS tool reading HERMES_SESSION_PLATFORM to pick Ogg/Opus vs MP3, but that contextvar is cleared by _clear_session_env before the base adapter's post-handler auto-TTS block runs, so want_opus was always False on that path → MP3 → Telegram sent an audio attachment instead of a native voice bubble (NousResearch#57049, NousResearch#36685). The runner's _send_voice_reply had the sibling bug: it hardcoded .ogg for Telegram only, leaving Matrix and Feishu runner voice replies as MP3 (NousResearch#14841, NousResearch#45557). Fix: new build_auto_tts_output_path(platform) in gateway/platforms/base.py hands an explicit .ogg temp path when the platform is in the TTS tool's OPUS_VOICE_PLATFORMS set (single source of truth — telegram/matrix/feishu/ whatsapp/signal), .mp3 otherwise. Used by BOTH delivery call sites: - BasePlatformAdapter auto-TTS block (also honors the tool's success flag and cleans up requested + returned paths) - GatewayRunner._send_voice_reply (replaces the telegram-only ternary) Fixes NousResearch#57049 Fixes NousResearch#36685 Refs NousResearch#14841 NousResearch#45557
What does this PR do?
Fixes Telegram auto-TTS voice replies returning MP3 audio cards instead of native Opus voice bubbles.
.oggdirectly; MP3/WAV-native providers use a conversion-safe intermediate before Opus conversion.output_pathbehavior, command/plugin configured formats, andvoice_compatibleopt-in semantics.Closes the gap left by stale PRs #31937 and #32539.
Type of Change
Verification
+538 / -75 lines across 6 files.