dimonier / tg2obsidian

This bot pulls new messages from a Telegram chat or group and puts them into Obsidian vault on a local machine
MIT License
107 stars 26 forks source link

На mac os не работает модуль whisper #19

Closed dipsy closed 1 month ago

dipsy commented 1 year ago

Все зависимости установлены согласно https://github.com/openai/whisper Бот не выдает ошибки. Картинки и текст добавляются нормально.

samas77 commented 1 year ago

Та же картина на debian и centOS. Если я верно понял ошибка в bot.log: ERROR Task exception was never retrieved future: <Task finished name='Task-11' coro=<Dispatcher._process_polling_updates() done, defined at /usr/local/lib/python3.10/site-packages/aiogram/dispatcher/dispatcher.py:407> exception=TypeError("join() argument must be str, bytes, or os.PathLike object, not 'NoneType'")> Traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/aiogram/dispatcher/dispatcher.py", line 415, in _process_polling_updates for responses in itertools.chain.from_iterable(await self.process_updates(updates, fast)): File "/usr/local/lib/python3.10/site-packages/aiogram/dispatcher/dispatcher.py", line 235, in process_updates return await asyncio.gather(tasks) File "/usr/local/lib/python3.10/site-packages/aiogram/dispatcher/handler.py", line 117, in notify response = await handler_obj.handler(args, *partial_data) File "/usr/local/lib/python3.10/site-packages/aiogram/dispatcher/dispatcher.py", line 256, in process_update return await self.message_handlers.notify(update.message) File "/usr/local/lib/python3.10/site-packages/aiogram/dispatcher/handler.py", line 117, in notify response = await handler_obj.handler(args, *partial_data) File "/media/test/t2o/tg2obsidian_bot.py", line 160, in handle_video file_name = unique_filename(message.video.file_name, config.photo_path) File "/media/test/t2o/tg2obsidian_bot.py", line 555, in unique_filename if not os.path.exists(os.path.join(path, file)): File "/usr/local/lib/python3.10/posixpath.py", line 90, in join genericpath._check_arg_types('join', a, p) File "/usr/local/lib/python3.10/genericpath.py", line 152, in _check_arg_types raise TypeError(f'{funcname}() argument must be str, bytes, or ' TypeError: join() argument must be str, bytes, or os.PathLike object, not 'NoneType'

UPD:

  1. проблема легко правиться тем что запуск скрипта выполняется из папки где скрипт лежит, надо будет поправить пути в скрипте
  2. Не во всех сообщениях с видео есть file_name пока поправил костылем: @dp.message_handler(content_types=[ContentType.VIDEO]) async def handle_video(message: Message):

video file name check

if message.video.file_name
   file_name = message.video.file_name
else
   file_name = message.video.file_id + '.mp4'

log_message(message)