From 953d521a375469abcdcccefe9735e1d6eb7bccc7 Mon Sep 17 00:00:00 2001 From: hibobmaster Date: Thu, 20 Apr 2023 01:51:00 +0800 Subject: [PATCH] fix invalid cross-device link --- bot.py | 19 ++++++++++--------- requirements.txt | 3 +-- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/bot.py b/bot.py index 4927ab0..a2ebbb1 100644 --- a/bot.py +++ b/bot.py @@ -10,7 +10,7 @@ from nio import (AsyncClient, AsyncClientConfig, InviteMemberEvent, JoinError, KeyVerificationCancel, KeyVerificationEvent, DownloadError, KeyVerificationKey, KeyVerificationMac, KeyVerificationStart, LocalProtocolError, LoginResponse, MatrixRoom, MegolmEvent, - RoomMessageAudio, RoomEncryptedAudio, ToDeviceError, crypto, + RoomMessageAudio, RoomEncryptedAudio, ToDeviceError, crypto, EncryptionError) from nio.store.database import SqliteStore @@ -19,8 +19,6 @@ from faster_whisper import WhisperModel from log import getlogger from send_message import send_room_message -from unsync import unsync - logger = getlogger() @@ -82,9 +80,10 @@ class Bot: self.num_workers = 1 if download_root is None: - self.download_root = "models" - if not os.path.exists("models"): - os.mkdir("models") + cwd = os.getcwd() + self.download_root = os.path.join(cwd, "models") + if not os.path.exists(self.download_root): + os.mkdir(self.download_root) # initialize AsyncClient object self.store_path = os.getcwd() @@ -112,10 +111,11 @@ class Bot: # intialize whisper model if not os.path.exists(os.path.join(self.download_root, "model.txt")): # that means we have not downloaded the model yet - logger.info("Model downloading") + logger.info("Model downloading......") self.model_size_or_path = self.model_size with open(os.path.join(self.download_root, "model.txt"), "w") as f: f.write(self.model_size) + f.close() else: # model exists f = open(os.path.join(self.download_root, "model.txt"), "r") @@ -508,7 +508,8 @@ class Bot: if isinstance(resp, EncryptionError): logger.error(f"import_keys failed with {resp}") else: - logger.info(f"import_keys success, please remove import_keys configuration!!!") + logger.info( + f"import_keys success, please remove import_keys configuration!!!") # whisper function def transcribe(self, filename: str) -> str: @@ -571,7 +572,7 @@ async def main(): if need_import_keys: logger.info("start import_keys process, this may take a while...") await bot.import_keys() - + await bot.sync_forever() if __name__ == '__main__': diff --git a/requirements.txt b/requirements.txt index d69fd9a..b4b95bd 100644 --- a/requirements.txt +++ b/requirements.txt @@ -20,7 +20,7 @@ future==0.18.3 h11==0.14.0 h2==4.1.0 hpack==4.0.0 -huggingface-hub==0.13.4 +huggingface-hub @ git+https://github.com/huggingface/huggingface_hub.git@a433410ac37f0efaacb92b09684efa3ae46ed3fd humanfriendly==10.0 hyperframe==6.0.1 idna==3.4 @@ -46,6 +46,5 @@ tokenizers==0.13.3 tqdm==4.65.0 typing_extensions==4.5.0 unpaddedbase64==2.1.0 -unsync==1.4.0 urllib3==1.26.15 yarl==1.8.2