fix invalid cross-device link

This commit is contained in:
hibobmaster 2023-04-20 01:51:00 +08:00
parent 70d8a8aa0c
commit 953d521a37
Signed by: bobmaster
GPG key ID: 316B77D7914D713C
2 changed files with 11 additions and 11 deletions

19
bot.py
View file

@ -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__':

View file

@ -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