Repository navigation
Description
Bug Description
When the agent sends a voice or audio reply on Telegram (auto-TTS / text_to_speech
delivery through TelegramAdapter.send_voice), clips longer than roughly 4 min 50 s
render as 0:00 in the Telegram player and the progress bar is unusable.
Telegram only auto-derives a clip's duration from container metadata for short
recordings. For longer ones it delivers the message with duration 0 unless the
sender passes an explicit duration to sendVoice / sendAudio. Hermes doesn't pass
one, so long voice/audio replies lose their duration.
Steps to Reproduce
- Configure the Telegram gateway with TTS enabled.
- Trigger a voice reply whose audio is longer than ~4:50 (e.g. a long
text_to_speech answer; I used a ~293 s clip). - Open the resulting voice/audio bubble in any Telegram client.
Expected Behavior
The bubble shows the real length (e.g. 4:53) with a working progress bar.
Actual Behavior
The bubble shows 0:00. The clip still plays but carries no duration metadata.
Affected Component
Gateway (Telegram/Discord/Slack/WhatsApp)
Messaging Platform (if gateway-related)
Telegram
Debug Report
in the attached file if neededOperating System
hermes_debug_share_sanitized.txt
Linux (also macOS Darwin 25.5)
Python Version
3.14.5
Hermes Version
0.15.1
Additional Logs / Traceback (optional)
Root Cause Analysis (optional)
gateway/platforms/telegram.py — send_voice calls self._bot.send_voice / send_audio
without a duration kwarg. python-telegram-bot forwards None, so Telegram falls back
to container-derived duration, which it omits for long clips → 0:00. Discord's adapter
already computes duration locally (plugins/platforms/discord/adapter.py); Telegram never did.
Proposed Fix (optional)
Probe the duration locally before sending and pass it explicitly to sendVoice/sendAudio.
Best-effort chain: stdlib wave (WAV) → mutagen (OGG/Opus/MP3/M4A) → ffprobe
(guarded by shutil.which). Omit duration when unreadable so behavior is unchanged
in that case. I have a focused, Telegram-only fix + hermetic tests ready and will open a PR.
This extracts/hardens the Telegram part of the stale, Piper-bundled PR #7815 (relates to #8508).
Are you willing to submit a PR for this?
- I'd like to fix this myself and submit a PR
Activity
szafranski commentedon May 31, 2026
liuhao1024 commentedon Jun 8, 2026
This is fixed by #36009 — fix(telegram): pass explicit duration to send_voice/send_audio.
teknium1 commentedon Jul 16, 2026
Fixed via #65535. Telegram voice/audio now carries a probed duration (wave → mutagen → ffprobe, off-thread), covering both the gateway adapter and the standalone send_message path. Salvaged from @szafranski's #36020.