diff --git a/10-systems/bots/gntranscribe.md b/10-systems/bots/gntranscribe.md index 664145c..fd5e308 100644 --- a/10-systems/bots/gntranscribe.md +++ b/10-systems/bots/gntranscribe.md @@ -26,6 +26,12 @@ - Multi-user: incoming media jobs go into an asyncio queue (max 20). - Single worker processes jobs one at a time — whisper-server shares a 4 GB GPU with Ollama on bserv-host, parallel inference is not safe there. +- Pipeline per job: download from Telegram CDN via aiohttp (PTB's default + 5 s read timeout is too slow for the CDN) → convert to 16 kHz mono WAV via + ffmpeg → POST to whisper → send transcript (chunked at 4000 chars). +- **whisper-server rejects ogg/opus with HTTP 400 "Invalid request"** — + Telegram voice messages are ogg/opus, hence the mandatory WAV conversion + (verified 2026-09-20: ogg → 400, wav → exact transcript). - Optional chat_id whitelist via `ALLOWED_CHAT_IDS` in `.env` (comma-separated; empty = open to everyone). Non-whitelisted users get their chat_id back with a deny message. @@ -33,14 +39,15 @@ setup), `/status` (queue size, worker state, counters, uptime). - Media accepted: voice, audio, video_note (circle), video, audio/video documents. Max file size 24 MB (configurable `MAX_FILE_MB`). -- Transcripts over 4096 chars are split into chunks. +- Whisper calls retried up to 3 attempts on network errors. ## Technical Details - **Host:** VM tg_bots (192.168.1.254), user `ubuntu` - **Path:** `/home/ubuntu/bots/GNtranscribe` — `bot.py`, `.env`, `requirements.txt`, `gntranscribe.service`, `venv/` -- **Stack:** Python 3.10, python-telegram-bot 21.10, aiohttp +- **Stack:** Python 3.10, python-telegram-bot 21.10, aiohttp, ffmpeg 4.4.2 + (system package, required for WAV conversion) - **systemd:** `gntranscribe.service` (User=ubuntu, Restart=always, RestartSec=30), enabled (multi-user.target.wants) - **Config (`.env`):** `BOT_TOKEN` (stored in gnexus-creds secret @@ -58,6 +65,9 @@ - Direct whisper test: TTS-generated Russian audio POSTed to http://192.168.1.130:8008/inference returned the exact expected text. - Service active after `enable --now`; two consecutive restarts passed. +- Live-message debugging: first failure was PTB 5 s download timeout + (fixed with aiohttp download), second was ogg/opus HTTP 400 from + whisper-server (fixed with ffmpeg WAV conversion; ogg→400, wav→ok verified). ## Operations