Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@Glucksberg
Copy link
Contributor

Summary

Adds a new Telegram TTS extension that converts text responses to audio using ElevenLabs or OpenAI APIs.

Note: This PR depends on #1558 (Plugin Command API). Please merge that first.

Key features:

  • Multiple TTS providers: ElevenLabs (default) and OpenAI
  • Auto-TTS mode: Automatically convert all bot responses to voice messages
  • Manual /audio command: On-demand TTS via LLM tool
  • Auto-summarization: Long texts (>1500 chars) are automatically summarized before TTS
  • Provider switching: /tts_provider command to switch between providers
  • Status tracking: /tts_status shows last attempt info with latency metrics
  • Configurable limits: /tts_limit to set max text length before summarization

Commands registered:

Command Description
/tts_on Enable auto-TTS mode
/tts_off Disable auto-TTS mode
/tts_status Show TTS status and last attempt info
/tts_provider Switch TTS provider (elevenlabs/openai)
/tts_limit Set/show max text length for TTS

Technical details:

  • Uses message_sending hook to intercept outbound messages
  • Generates audio files in temp directory with automatic cleanup
  • Returns MEDIA:/path directive for audio delivery
  • Integrates with the new Plugin Command API for slash commands

Files changed:

  • extensions/telegram-tts/ - New extension package
    • index.ts - Main extension code (~1000 lines)
    • index.test.ts - Unit tests (21 tests)
    • clawdbot.plugin.json - Plugin manifest
    • package.json - Package definition
    • README.md - Documentation
  • src/auto-reply/reply/route-reply.ts - Hook integration for routing
  • src/telegram/bot/delivery.ts - Hook integration for Telegram delivery

Test plan

  • Unit tests pass (pnpm test extensions/telegram-tts)
  • Manual testing of auto-TTS with long text (>1500 chars) - summarization works
  • Test provider switching between ElevenLabs and OpenAI
  • Verify audio files are cleaned up after delivery

🤖 Generated with Claude Code

@steipete
Copy link
Contributor

steipete commented Jan 24, 2026

I wonder if that shouldn't be part of our https://docs.clawd.bot/nodes/media-understanding feature?
Will read more.

Edit: Ah this is outbound. Would replace sag. I like.

Glucksberg and others added 7 commits January 24, 2026 07:10
Add a new extension that provides automatic text-to-speech for chat
responses using ElevenLabs API.

Features:
- `speak` tool for converting text to voice messages
- RPC methods: tts.status, tts.enable, tts.disable, tts.convert
- User preferences file for persistent TTS state
- Configurable voice ID, model, and max text length

Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Remove sag CLI dependency
- Add direct ElevenLabs API integration via fetch
- Add OpenAI TTS as alternative provider
- Support multi-provider configuration
- Add tts.providers RPC method
- Update config schema with OpenAI options
- Bump version to 0.2.0

Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Integrate message_sending hook into Telegram delivery path
- Send text first, then audio as voice message after
- Add /tts_provider command to switch between OpenAI and ElevenLabs
- Implement automatic fallback when primary provider fails
- Use gpt-4o-mini-tts as default OpenAI model
- Add hook integration to route-reply.ts for other channels

Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Add /tts_limit command to configure max text length (default 1500)
- Auto-summarize long texts with gpt-4o-mini before TTS conversion
- Add truncation safeguard if summary exceeds hard limit
- Validate targetLength parameter (100-10000)
- Use conservative max_tokens for multilingual text
- Add prompt injection defense with XML delimiters

Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Add latency metrics to summarizeText and textToSpeech functions
- Add /tts_status command showing config and last attempt result
- Add /tts_summary command for feature flag control
- Fix atomic write to clean up temp file on rename failure
- Add timer.unref() to prevent blocking process shutdown
- Add unit tests for validation functions (13 tests)
- Update README with new commands and features

Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Export summarizeText in _test for testing
- Add 8 tests covering:
  - Successful summarization with metrics
  - OpenAI API call parameters verification
  - targetLength validation (min/max boundaries)
  - Error handling (API failures, empty responses)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@steipete steipete merged commit d9a467f into openclaw:main Jan 24, 2026
20 of 22 checks passed
@steipete
Copy link
Contributor

Landed via rebase onto main.

  • Gate: pnpm lint && pnpm build && pnpm test
  • Land commit: ff71e08
  • Merge commit: d9a467f

Thanks @Glucksberg!

steipete added a commit that referenced this pull request Jan 24, 2026
Glucksberg added a commit to Glucksberg/clawdbot that referenced this pull request Jan 25, 2026
PR clawdbot#1630 (LINE plugin) accidentally removed the detailed TTS command
definition with args and argsMenu, replacing it with a simplified
version. This restores the original functionality from PR clawdbot#1559.

Fixes regression where /tts no longer showed the inline action menu
on Telegram and other native command surfaces.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
mcinteerj pushed a commit to mcinteerj/moltbot that referenced this pull request Jan 25, 2026
mcinteerj pushed a commit to mcinteerj/moltbot that referenced this pull request Jan 25, 2026
Glucksberg added a commit to Glucksberg/clawdbot that referenced this pull request Jan 28, 2026
PR moltbot#1630 (LINE plugin) accidentally removed the detailed TTS command
definition with args and argsMenu, replacing it with a simplified
version. This restores the original functionality from PR moltbot#1559.

Fixes regression where /tts no longer showed the inline action menu
on Telegram and other native command surfaces.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants