A Telegram bot that automatically transcribes voice messages into text using OpenAI's Whisper model.
- Automatic transcription of voice messages to text
- Support for both groups and private conversations
- Automatic activation when added to a group
- Automatic cleanup of temporary files
- Audio quality optimization before transcription
- Python 3.11+
- FFmpeg
- A Telegram bot token (obtained from @BotFather)
- Clone the repository:
git clone https://github.com/[your-username]/telegram-voice-transcription-bot.git
cd telegram-voice-transcription-bot-
Configure your Telegram token in
config.pyor via environment variable -
Build and run the container:
docker build -t voice-transcription-bot .
docker run -d voice-transcription-bot- Clone the repository:
git clone https://github.com/[your-username]/telegram-voice-transcription-bot.git
cd telegram-voice-transcription-bot- Install dependencies:
pip install -r requirements/dev.txt
# Or for production
pip install -r requirements/prod.txt- Install FFmpeg:
- On Debian/Ubuntu:
sudo apt-get install ffmpeg
- On macOS:
brew install ffmpeg
-
Configure your environment:
- Create a
.envfile in the project root directory - Add your Telegram bot token:
TELEGRAM_BOT_TOKEN=your-token-here LOGGING_LEVEL=INFO # Logging level (DEBUG, INFO, WARNING, ERROR) WHISPER_MODEL=large-v3 # Model name (large-v3, base, etc.) WHISPER_DEVICE=cpu # Device (cpu, cuda) WHISPER_COMPUTE_TYPE=int8 # Compute type (int8, fp16, fp32) AUDIO_LANGUAGE=fr # Language code (en, fr, es, etc.) AUDIO_INITIAL_PROMPT=Transcription of a French voice message. # Initial prompt for Whisper
- Create a
-
Run the bot:
python main.py-
Start a private conversation with the bot or add it to a group
-
In private conversation:
- Send a voice message
- The bot will automatically transcribe the message
-
In group:
- Add the bot to the group
- The bot activates automatically
- Send a voice message
- The bot will reply with the transcription
- python-telegram-bot - Framework for Telegram bots
- faster-whisper - Optimized implementation of Whisper
- pydub - Audio manipulation