Skip to content

pizidavi/lazy-listener

Repository files navigation

Lazy Listener 🤖

License: MIT

A Telegram bot that transcribes voice messages into text. Works in private chats and groups.
Built with HonoJS and deployed on Cloudflare Workers.

How it works

  • The bot downloads the audio file from Telegram.
  • It transcribes audio using OpenAI's Whisper Large V3 Turbo model. 🎧
  • The raw transcription is then cleaned and lightly refactored by Google's Gemma 4 26b a4b IT model. ✨

Costs

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.

Development

Requirements

  • A Cloudflare Workers account
  • A Telegram bot token (create one with @BotFather)
  • Mise (optional) for managing tool versions

  1. Install project tools (if you're using Mise):

    mise install
  2. Install dependencies:

    bun install
  3. Create a .env file with:

    • ENV (optional): development|preview|production (defaults to production)
    • TELEGRAM_BOT_TOKEN: your Telegram bot token
    • TELEGRAM_WEBHOOK_SECRET: secret used to validate incoming webhook requests (see Telegram's setWebhook docs)
  4. 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\"]}"
  5. Start the dev server:

    bun dev

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

Telegram bot that transcribes voice messages into text. Works in private chats and groups.

Topics

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Contributors