feat: preload Whisper model at startup with disk space check

- Add WHISPER_MODEL_SIZE and WHISPER_MIN_FREE_SPACE_BYTES config options
- voice.py now preloads/downloads the Whisper model at bot startup
- Detailed logging for model presence, disk space, download progress and readiness
- If model is already present locally, preload is skipped
- If disk space is insufficient, bot fails fast with a clear error
- main.py calls preload_model() after proxy setup and before polling
- Document voice recognition model download behavior in README
This commit is contained in:
Галингер Р.С.
2026-07-08 09:44:48 +07:00
parent 0432155c8f
commit d6c029f708
4 changed files with 137 additions and 7 deletions
+9
View File
@@ -13,6 +13,7 @@ from bot.routers import moderation, layout, weather, ai, voice, yadisk, dialogue
from bot.utils.database import init_db, save_chat_user
from bot.utils.ai_client import start_model_health_check
from bot.utils.logging_config import setup_logging
from bot.utils.voice import preload_model
from bot.setup_commands import setup_bot_commands
from config import PROXY_ENABLED
@@ -75,6 +76,14 @@ async def main():
health_check_task.cancel()
return
try:
await preload_model()
logging.info("Модель Whisper готова к работе")
except Exception as exc:
logging.error("Не удалось загрузить модель Whisper: %s", exc)
health_check_task.cancel()
return
try:
await dp.start_polling(bot)
finally: