mirror of
https://github.com/ergolyam/whisper_tg_bot.git
synced 2025-12-05 20:38:12 +00:00
this bot to transcribe tg voice messages.
| .github/workflows | ||
| config | ||
| core | ||
| recognition | ||
| .gitignore | ||
| dockerfile | ||
| main.py | ||
| pyproject.toml | ||
| pyrightconfig.json | ||
| readme.md | ||
| uv.lock | ||
whisper_tg_bot
Telegram bot and user bot that utilizes the Whisper model for transcription of voice messages and video notes. It is designed to run with arguments such as token, CPU threads, and model size. The bot uses Pyrogram library for interaction with Telegram, and it employs asyncio and threading for asynchronous and parallel processing.
Initial Setup
- Clone the repository: Clone this repository using
git clone. - Create Virtual Env: Create a Python Virtual Env
venvto download the required dependencies and libraries. - Download Dependencies: Download the required dependencies into the Virtual Env
venvusingpip.
git clone https://github.com/ergolyam/whisper_tg_bot.git
cd whisper_tg_bot
python -m venv .venv
.venv/bin/python -m pip install uv
.venv/bin/python -m uv sync
Deploy
-
Run the bot:
TG_TOKEN="your_telegram_bot_token" CPU_THREADS="4" MODEL_SIZE="tiny" uv run main.py -
Other working env's:
LOG_LEVEL="INFO" MODE="bot" #bot, user, mixed TG_ID="your_telegram_api_id" TG_HASH="your_telegram_api_hash" TG_TOKEN="your_telegram_bot_token" CPU_THREADS="number" MODEL_SIZE="tiny" #tiny, tiny.en #base, base.en #small, small.en #medium, medium.en #large-v1, large-v2 #large-v3, or large
Container
-
Pull container:
podman pull ghcr.io/ergolyam/whisper_tg_bot:latest -
Deploy in container as bot:
mkdir -p $HOME/whisper_cache/ && \ podman run --tmpfs /tmp \ --name whisper_tg_bot \ -v $HOME/whisper_cache/:/root/.cache/huggingface/:z \ -e MODE="bot" \ -e TG_TOKEN="your_telegram_bot_token" \ -e MODEL_SIZE="tiny" \ -e CPU_THREADS="4" \ ghcr.io/ergolyam/whisper_tg_bot:latest -
Deploy in container as user bot:
mkdir -p $HOME/whisper_cache/ && \ mkdir -p $HOME/sessions/ && \ podman run --tmpfs /tmp \ --name whisper_tg_bot \ -v $HOME/whisper_cache/:/root/.cache/huggingface/:z \ -v $HOME/sessions/:/app/sessions/:z \ -e MODE="user" \ -e TG_ID="your_telegram_api_id" \ -e TG_HASH="your_telegram_api_hash" \ -e MODEL_SIZE="tiny" \ -e CPU_THREADS="4" \ ghcr.io/ergolyam/whisper_tg_bot:latest
use MODE="mixed" to combine modes
Features
- Transcribes
voice messagesandvideo notesinto text using the Whisper model. - Supports multiple Whisper model sizes for transcription.
- Utilizes multithreading for efficient processing of
voice messagesand video notes. - Selection of the bot operating
mode, as auserbot or as aregularbot, as well asmixedmode.