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:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user