fix(gateway): pass explicit .ogg output_path for Telegram auto-TTS - #57071
Closed
liuhao1024 wants to merge 1 commit into
Closed
fix(gateway): pass explicit .ogg output_path for Telegram auto-TTS#57071liuhao1024 wants to merge 1 commit into
liuhao1024 wants to merge 1 commit into
Conversation
The base platform adapter's auto-TTS block calls text_to_speech_tool without an output_path. The tool uses get_session_env() to detect the platform, but the session contextvar is not populated at this call site (it is set by _set_session_env() inside _handle_message_with_agent and cleared on return). The tool defaults to .mp3, causing Telegram to render sendAudio instead of sendVoice. Fix: build an explicit output_path with the correct extension (.ogg for Telegram, .mp3 otherwise) based on self.platform, which is always available on the adapter instance. Regression test included. Fixes NousResearch#57049
13 tasks
Contributor
|
Thanks for tracing the base-adapter auto-TTS path; the current-main premise is valid: Problems
Suggested changes
Automated hermes-sweeper review. |
Contributor
|
The root cause here (gateway auto-TTS choosing MP3 vs Ogg/Opus via the cleared (Landed via #73508, merge |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Fixes a bug where the base platform adapter's auto-TTS path calls
text_to_speech_toolwithout an explicitoutput_path, causing Telegram voice replies to be sent as regular audio attachments (sendAudio) instead of native voice bubbles (sendVoice).The root cause:
text_to_speech_toolusesget_session_env("HERMES_SESSION_PLATFORM")to detect the platform and choose the output format. The session contextvar is set by_set_session_env()inside_handle_message_with_agent()and cleared on return. The auto-TTS code inbase.py's_process_message_backgroundruns after the agent returns, so the contextvar is empty — the tool defaults to.mp3regardless of platform.The fix: pass an explicit
output_pathwith the correct extension (.oggfor Telegram,.mp3otherwise) based onself.platform, which is always available on the adapter instance.Related Issue
Fixes #57049
Type of Change
Changes Made
gateway/platforms/base.py: Build an explicitoutput_pathwith the correct extension based onself.platformbefore callingtext_to_speech_toolin the auto-TTS block. Addedimport tempfile.tests/gateway/test_base_topic_sessions.py: Added regression testtest_telegram_auto_tts_passes_explicit_ogg_output_pathverifying that the TTS tool receives an.oggoutput_path on Telegram.How to Test
python -m pytest tests/gateway/test_base_topic_sessions.py -q— all 11 tests should passself.platform == Platform.TELEGRAMand auto-TTS is enabled,text_to_speech_toolis called withoutput_pathending in.oggvoice.auto_tts: trueandtts.provider: edge, voice replies should render as native voice bubbles (tap-to-play) instead of audio file attachmentsChecklist
Code
fix(scope):,feat(scope):, etc.)python -m pytest tests/gateway/test_base_topic_sessions.py -qand all 11 tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/Aself.platformattribute)Screenshots / Logs
N/A — regression test validates the fix programmatically.