Skip to content

[Bug]: Telegram voice/audio longer than ~4:50 shows 0:00 (duration not set on send) #36005

Closed

Description

@szafranski

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

  1. Configure the Telegram gateway with TTS enabled.
  2. 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).
  3. 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 needed

Operating 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

  1. szafranski commented on May 31, 2026

    @szafranski
    Author

    Image that's how it looks without duration declared when voice message is longer than 4:50

  2. added
    type/bugSomething isn't working
    P2Medium — degraded but workaround exists
    comp/gatewayGateway runner, session dispatch, delivery
    tool/ttsText-to-speech and transcription
    on May 31, 2026
  3. liuhao1024 commented on Jun 8, 2026

    @liuhao1024

    This is fixed by #36009 — fix(telegram): pass explicit duration to send_voice/send_audio.

  4. teknium1 commented on Jul 16, 2026

    @teknium1
    Collaborator

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Medium — degraded but workaround existscomp/gatewayGateway runner, session dispatch, deliveryplatform/telegramTelegram bot adaptertool/ttsText-to-speech and transcriptiontype/bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions