openclaw - ✅(Solved) Fix TTS tool on Telegram renders as audio file instead of native voice memo (sendAudio vs sendVoice) [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#44459Fetched 2026-04-08 00:46:42
View on GitHub
Comments
0
Participants
1
Timeline
5
Reactions
0
Timeline (top)
referenced ×3cross-referenced ×1subscribed ×1

The built-in tts tool on Telegram delivers voice audio using sendAudio (or sendDocument) instead of sendVoice. This causes voice memos to render as generic audio files with clunky metadata (filename, "Unknown artist", music note icon) instead of native Telegram voice memos with a clean waveform UI.

Root Cause

The built-in tts tool on Telegram delivers voice audio using sendAudio (or sendDocument) instead of sendVoice. This causes voice memos to render as generic audio files with clunky metadata (filename, "Unknown artist", music note icon) instead of native Telegram voice memos with a clean waveform UI.

Fix Action

Fixed

PR fix notes

PR #44504: fix(tts): use OGG/Opus for edge-tts on Telegram to render native voice memos

Description (problem / solution / changelog)

Summary

Fixes edge-TTS audio rendering as a generic audio file on Telegram instead of a native voice memo with waveform UI.

Problem

The built-in tts tool on Telegram delivers edge-TTS voice audio using MP3 format, which causes Telegram to render it as a generic audio file attachment (with filename, "Unknown artist" metadata, and music note icon) instead of a native voice memo with inline waveform playback.

OpenAI and ElevenLabs providers already switch to Opus output when the target channel is Telegram/Feishu/WhatsApp (voice-bubble channels), but edge-TTS was missing this channel-aware format selection — it always used config.edge.outputFormat (default: audio-24khz-48kbitrate-mono-mp3) regardless of channel.

Changes

  • src/tts/tts.ts:

    • Added edge: "ogg-24khz-16bit-mono-opus" to TELEGRAM_OUTPUT constant
    • Made resolveEdgeOutputFormat() channel-aware: when the target is a voice-bubble channel and the user hasn't explicitly configured a custom edge output format, it returns OGG/Opus instead of MP3
    • Passes channelId through to the edge-tts format resolver in textToSpeech()
  • src/tts/tts.test.ts: Added 3 test cases covering:

    • OGG/Opus selection for voice-bubble channels (telegram/feishu/whatsapp)
    • MP3 preserved for non-voice-bubble channels (discord, null, undefined)
    • User-configured edge format respected even on voice-bubble channels

Backward Compatibility

  • Non-Telegram channels still get MP3 (default behavior unchanged)
  • Users who explicitly set messages.tts.edge.outputFormat in config keep their preference (the override only applies when outputFormatConfigured is false)
  • Only the default edge format is overridden for voice-bubble channels

Testing

All 35 TTS tests pass including the 3 new ones. Audio compatibility tests (23 tests) also pass.

Closes #44459

Changed files

  • src/tts/tts.test.ts (modified, +28/-0)
  • src/tts/tts.ts (modified, +12/-2)
RAW_BUFFERClick to expand / collapse

Summary

The built-in tts tool on Telegram delivers voice audio using sendAudio (or sendDocument) instead of sendVoice. This causes voice memos to render as generic audio files with clunky metadata (filename, "Unknown artist", music note icon) instead of native Telegram voice memos with a clean waveform UI.

Screenshot

Side-by-side comparison on Telegram:

  • Top: Audio sent via Telegram sendVoice API — renders as a native voice memo with waveform, inline playback, no filename. Clean.
  • Bottom: Audio from OpenClaw built-in tts tool — renders as voice-177335826285... / Unknown artist with a music file icon. Clunky.

Both contain the same type of content (TTS-generated speech). The only difference is the Telegram API method used to send them.

Expected Behavior

When the tts tool is used on a Telegram channel, the audio should be sent via Telegram's sendVoice API endpoint so it renders as a native voice memo with:

  • Inline waveform
  • No filename displayed
  • No "Unknown artist" metadata
  • Native voice memo playback UX

Current Behavior

The TTS audio is sent via sendAudio or sendDocument, causing it to display as a generic audio file attachment with:

  • Filename shown (e.g. voice-1773358262852.mp3)
  • "Unknown artist" label
  • Music note icon instead of voice waveform
  • Non-native playback UX

Environment

  • OpenClaw version: 2026.3.8
  • Channel: Telegram (polling mode)
  • TTS provider: built-in (edge-tts)
  • Docker on WSL2

Notes

The sendVoice API accepts mp3, ogg/opus, and other formats. The TTS tool already generates mp3 files, so no format conversion is needed — just changing the Telegram API method from sendAudio/sendDocument to sendVoice should fix the rendering.

Telegram docs: https://core.telegram.org/bots/api#sendvoice

extent analysis

Fix Plan

To fix the issue, we need to modify the tts tool to use the sendVoice API instead of sendAudio or sendDocument. Here are the steps:

  • Update the tts tool to import the sendVoice method from the Telegram API
  • Modify the tts tool to use the sendVoice method to send the audio file
  • Ensure the audio file is in a supported format (e.g. mp3, ogg/opus)

Example code:

import telegram

# Assuming 'bot' is an instance of telegram.Bot
def send_tts_audio(bot, chat_id, audio_file):
    # Use sendVoice instead of sendAudio or sendDocument
    bot.send_voice(chat_id=chat_id, voice=open(audio_file, 'rb'))

Verification

To verify the fix, send a voice memo using the updated tts tool and check that it renders as a native voice memo with:

  • Inline waveform
  • No filename displayed
  • No "Unknown artist" metadata
  • Native voice memo playback UX

Extra Tips

  • Make sure to handle any errors that may occur when sending the voice memo, such as network errors or invalid audio files.
  • Consider adding logging to track any issues that may arise during the sending process.
  • Refer to the Telegram API documentation for more information on the sendVoice method and its parameters.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING