Skip to content

fix(gateway): request ogg for telegram auto tts - #57192

Closed
tianma-if wants to merge 1 commit into
NousResearch:mainfrom
tianma-if:codex/fix-base-auto-tts-telegram-ogg
Closed

fix(gateway): request ogg for telegram auto tts#57192
tianma-if wants to merge 1 commit into
NousResearch:mainfrom
tianma-if:codex/fix-base-auto-tts-telegram-ogg

Conversation

@tianma-if

@tianma-if tianma-if commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Summary

  • carry the destination platform explicitly into both gateway auto-TTS paths, including after inbound session ContextVars have been cleared
  • keep conversion-backed providers on a real source path (Edge writes MP3), then return the converted OGG/Opus path for Telegram
  • let native-Opus providers select .ogg from delivery intent rather than relying on a caller-provided suffix
  • keep non-Telegram delivery on the existing MP3 behavior

Verification

  • pytest -q tests/tools/test_tts_*.py tests/gateway/test_auto_voice_reply_format.py tests/gateway/test_base_topic_sessions.py (262 passed)
  • Ruff passes for all modified implementation and test files

@alt-glitch alt-glitch added type/bug Something isn't working comp/gateway Gateway runner, session dispatch, delivery tool/tts Text-to-speech and transcription platform/telegram Telegram bot adapter sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages P2 Medium — degraded but workaround exists labels Jul 2, 2026

@teknium1 teknium1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for tracing the adapter-level path; the missing context after the runner returns is real. However, the proposed filename change is not sufficient for conversion-backed providers.

Problems

  • gateway/platforms/base.py:4978 passes a .ogg path to text_to_speech_tool, but Edge writes MP3 output (tools/tts_tool.py:947-971). Opus conversion only runs when want_opus is true and the produced path is not already .ogg (tools/tts_tool.py:2562-2570). The adapter call occurs after GatewayRunner clears the session context (gateway/run.py:12448-12450), so this path has want_opus == false; the result can be MP3 bytes under an .ogg name.
  • The test only checks the mocked requested suffix, so it cannot prove conversion or valid Opus delivery.
  • gateway/run.py:13302-13310 has the same output-path pattern and should be handled with the same corrected mechanism.

Suggested changes

  • Carry explicit Telegram/Opus intent into the TTS layer and preserve a real conversion input for Edge/WAV-backed providers; cover the converted result, not only the requested filename.
  • Apply that mechanism to both auto-TTS call paths.

Automated hermes-sweeper review.

Comment thread gateway/platforms/base.py
text_to_speech_tool, text=speech_text
text_to_speech_tool,
text=speech_text,
output_path=audio_path,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A .ogg suffix alone is not an Opus payload. Edge writes MP3 output, and text_to_speech_tool only calls _convert_to_opus when want_opus is true and the generated path does not already end in .ogg (tools/tts_tool.py:2562-2570). Here the runner has already cleared the session context, so this can send MP3 bytes under an .ogg name. Please pass explicit delivery intent into TTS and preserve a real conversion input instead.

@teknium1 teknium1 added the sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform label Jul 15, 2026
@tianma-if
tianma-if force-pushed the codex/fix-base-auto-tts-telegram-ogg branch from e2873c3 to 750e1f7 Compare July 16, 2026 11:02
@teknium1

Copy link
Copy Markdown
Contributor

The root cause here (gateway auto-TTS choosing MP3 vs Ogg/Opus via the cleared HERMES_SESSION_PLATFORM contextvar, so opus platforms got audio attachments instead of native voice bubbles) was fixed class-wide in #73508: platform-awareness now comes from the caller via build_auto_tts_output_path(platform) keyed off OPUS_VOICE_PLATFORMS (based on @giladbau's #62040), with the central container repair guaranteeing real Ogg/Opus bytes.

(Landed via #73508, merge f440a44753.) Closing.

@teknium1 teknium1 closed this Jul 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists platform/telegram Telegram bot adapter sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages tool/tts Text-to-speech and transcription type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants