A no-frills Telegram bot that turns Russian text messages into voice with Yandex SpeechKit.
- Python 3.10+ and a Telegram bot token from @BotFather are required.
- Enable Yandex SpeechKit, grab an API key.
pip install -r requirements.txt- Copy
.env.example➜.envand fill in your keys. python bot.py— the bot starts in polling mode.
TELEGRAM_BOT_TOKEN=... # required
YANDEX_API_KEY=... # required
YANDEX_FOLDER_ID=... # required for SSML support
/start– short help/help– detailed help/set_voice,/set_role,/set_speed– pick voice / emotion / speed/settings– show current settings/reset– reset all settings to defaults/speak_ssml– synthesize speech with SSML markup (v1 API)/toggle_format– enable/disable AI-powered text formatting/demo_markup– see examples of TTS v3 markup
The bot supports Yandex SpeechKit v3's native TTS markup for natural speech synthesis:
sil<[ms]>— explicit pause with duration (100-5000ms)+— lexical stress on vowel (e.g., м+олоко)<[size]>— context-dependent pause (tiny/small/medium/large/huge)**word**— emphasis on word
Привет, sil<[300]> мир! # 300ms pause
Стоп! sil<[500]> Подумай об этом. # 500ms pause after exclamation
Унылая пора! sil<[300]> Очей очарованье! # Poetry with pauses
Зам+ок на двери и з+амок короля # Different stress for different meanings
When enabled, the bot uses YandexGPT to automatically add appropriate pauses and stress markers:
Input: "Мороз и солнце; день чудесный!"
Output: "Мороз и солнце; sil<[200]> день чудесный!"
Toggle this feature with /toggle_format.
For backward compatibility, the bot still supports SSML via the /speak_ssml command:
/speak_ssml <speak>Вот несколько примеров использования SSML. Вы можете добавить в текст паузу любой длины:<break time="2s"/> та-дааам!</speak>
Note: SSML uses the v1 API and is ~3× slower than v3 markup. Use TTS markup for better performance.
| Feature | SSML (v1) | TTS Markup (v3) |
|---|---|---|
| Latency | ~1.8s | ~0.6s |
| Syntax | XML tags | Simple markers |
| AI Format | NO | YES |
Running on Yandex Cloud Functions? Use the handler entry-point inside bot.py and set the same environment variables.
I like to keep my deployments flexible, so here's how I run EchoSage inside a container:
# Build it
docker build -t echosage-bot .
# Run it (loads your .env automatically)
docker run -d --env-file .env echosage-botFor an even simpler setup, I just run:
# Fire it up
docker-compose up --build -d
# Check what's happening
docker-compose logs -f echosage# Plain Docker: find container ID first
docker ps
docker stop <container_id>
# Docker Compose: just kill it
docker-compose downPublic domain (see LICENSE). Enjoy!