SuperAPI AI Directory

telegram-offline-voice

General & other

View repository

Updated 10-16 09:34

About this skill

telegram-offline-voice 🎙️

Local generation, one-click packaging — Use Microsoft Edge-TTS to generate high-quality Chinese speech, fully offline.

💡 Why is this upgrade needed?

Native TTS solutions usually can only generate MP3 attachments and cannot handle Markdown markup and overly long text. Through engineering encapsulation, this project evolves "speech synthesis" into "voice interaction":

  • Say goodbye to markup sounds: Automatically recognize and clean **, #, [link] and other Markdown symbols, preventing the AI from reading out this "code noise."
  • Smart conversation flow: Overly long text is no longer read all the way through; instead, it is automatically split into multiple voice bubbles by periods and exclamation marks, making it sound more like a real person sending voice messages.
  • Concurrency safety: For scenarios with parallel calls from multiple agents/sub-agents, UUIDs are used to isolate temporary files, completely eliminating file read/write conflicts.
  • Zero token consumption: Completely based on local Edge-TTS generation, with no paid OpenAI/Azure tokens required.

✨ Features

  • 🔒 Privacy protection: 100% local audio processing, without going through any additional cloud TTS provider.
  • 💰 Zero token consumption: Uses the free Edge-TTS engine, saving expensive API quota.
  • 🎯 One-click generation: Built-in voice_gen.py script, automatically completing the entire process of "text->MP3->OGG."
  • 🧹 Automatic cleaning: Automatically removes Markdown symbols and URL links, making reading more natural.
  • ✂️ Smart segmentation: Overly long text is automatically split into multiple voice bubbles by punctuation.
  • 🛡️ Safe concurrency: Uses UUIDs to name temporary files, supporting simultaneous calls from multiple agents.

🛠️ Install dependencies

# 需要 Python 环境和 FFmpeg
sudo apt update && sudo apt install ffmpeg python3-pip -y

# 推荐安装 uv 以极速运行封装脚本
curl -LsSf https://astral.sh/uv/install.sh | sh

🚀 Usage (recommended)

Directly call the wrapper script to generate a Telegram native voice bubble path in one click:

uv run {baseDir}/scripts/voice_gen.py --text "您的待播报内容"

⚙️ Technical details

Parameter description

  • --text / -t: The text to be generated (required).
  • --voice: Voice selection, default zh-CN-XiaoxiaoNeural(Xiaoxiao).
  • --rate: Speech rate adjustment, default +5%。
  • --outdir: Temporary file storage directory, default /tmp。

Automated cleaning rules

The script automatically removes the following content to ensure smooth reading:

  • Markdown symbols:**, *, _, `, #
  • Link logic:[文本](url) and all links starting with http/https link at the beginning
  • Dividing lines:---, *** , etc.

👨💻 About the author

Tuned and maintained by @sanwe . Welcome to follow my Twitter for more advanced OpenClaw tips:https://x.com/sanwe