A Telegram bot that transcribes voice messages into text. Works in private chats and groups.
Built with HonoJS and deployed on Cloudflare Workers.
- The bot downloads the audio file from Telegram.
- It transcribes audio using OpenAI's
Whisper Large V3 Turbomodel. 🎧 - The raw transcription is then cleaned and lightly refactored by Google's
Gemma 4 26b a4b ITmodel. ✨
Processing a voice message costs approximately $0.00058 per minute of audio.
Breakdown:
Assumes average speech rate of 130 words/min (~277 LLM tokens)
- Whisper Large V3 Turbo: 46.63 neurons per audio minute
- Gemma 4 26b a4b IT: ~27.88 neurons per minute
- Input: ~442 tokens (277 for speech + 165 system prompt) → 4.02 neurons
- Output: ~277 tokens → 2.52 neurons
Total: ~53.17 neurons/min ≈ $0.00058/min (at 1000 neurons = $0.011)
The free Cloudflare Worker AI plan offers 10,000 neurons per day, equivalent to over 3 hours of audio messages.
- A Cloudflare Workers account
- A Telegram bot token (create one with @BotFather)
- Mise (optional) for managing tool versions
-
Install project tools (if you're using Mise):
mise install
-
Install dependencies:
bun install
-
Create a
.envfile with:ENV(optional):development|preview|production(defaults toproduction)TELEGRAM_BOT_TOKEN: your Telegram bot tokenTELEGRAM_WEBHOOK_SECRET: secret used to validate incoming webhook requests (see Telegram's setWebhook docs)
-
Set Telegram bot webhook:
curl -s -X POST "https://api.telegram.org/bot${TELEGRAM_BOT_TOKEN}/setWebhook" \ -H "Content-Type: application/json" \ -d "{\"url\":\"https://your-domain.example.com/webhook\",\"secret_token\":\"${TELEGRAM_WEBHOOK_SECRET}\",\"allowed_updates\":[\"message\",\"callback_query\"]}"
-
Start the dev server:
bun dev
This project is licensed under the MIT License - see the LICENSE file for details.