From 49b53aee2ef443afffca1562bb5277bf09df43f4 Mon Sep 17 00:00:00 2001 From: misyaguziya Date: Sat, 27 Jan 2024 00:28:33 +0900 Subject: [PATCH 1/4] =?UTF-8?q?=F0=9F=90=9B[bugfix]=20Model=20:=20tqdm?= =?UTF-8?q?=E3=82=92=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- model.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/model.py b/model.py index 8580e85d..573659a7 100644 --- a/model.py +++ b/model.py @@ -12,7 +12,6 @@ from threading import Thread, Event from requests import get as requests_get import webbrowser -from tqdm import tqdm from typing import Callable from flashtext import KeywordProcessor from models.translation.translation_translator import Translator @@ -267,16 +266,13 @@ class Model: with tempfile.TemporaryDirectory() as tmp_path: res = requests_get(url, stream=True) file_size = int(res.headers.get('content-length', 0)) - pbar = tqdm(total=file_size, unit="B", unit_scale=True) total_chunk = 0 with open(os_path.join(tmp_path, filename), 'wb') as file: for chunk in res.iter_content(chunk_size=1024*5): file.write(chunk) - pbar.update(len(chunk)) if isinstance(func, Callable): total_chunk += len(chunk) func(total_chunk/file_size) - pbar.close() with ZipFile(os_path.join(tmp_path, filename)) as zf: zf.extractall(os_path.join(current_directory, tmp_directory_name)) From 3f40a77b02fa39d6cf65139597eeab6c30b06c93 Mon Sep 17 00:00:00 2001 From: misyaguziya Date: Sun, 28 Jan 2024 05:54:08 +0900 Subject: [PATCH 2/4] =?UTF-8?q?=F0=9F=90=9B[bugfix]=20Model=20:=20DeepL=5F?= =?UTF-8?q?API=E3=81=AE=E5=A0=B4=E5=90=88=E3=81=AETarget=E3=81=AE=E8=A8=80?= =?UTF-8?q?=E8=AA=9E=E3=82=B3=E3=83=BC=E3=83=89=E3=81=AE=E8=A8=AD=E5=AE=9A?= =?UTF-8?q?=E5=87=A6=E7=90=86=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- models/translation/translation_translator.py | 33 +++++++++++++------- 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/models/translation/translation_translator.py b/models/translation/translation_translator.py index fbe6cf3f..f3d3c99e 100644 --- a/models/translation/translation_translator.py +++ b/models/translation/translation_translator.py @@ -38,11 +38,30 @@ class Translator(): ) self.ctranslate2_tokenizer = transformers.AutoTokenizer.from_pretrained(tokenizer) + @staticmethod + def getLanguageCode(translator_name, target_country, source_language, target_language): + match translator_name: + case "DeepL_API": + if target_language == "English": + if target_country in ["United States", "Canada", "Philippines"]: + target_language = "English American" + else: + target_language = "English British" + elif target_language == "Portuguese": + if target_country in ["Portugal"]: + target_language = "Portuguese European" + else: + target_language = "Portuguese Brazilian" + case _: + pass + source_language=translation_lang[translator_name]["source"][source_language] + target_language=translation_lang[translator_name]["target"][target_language] + return source_language, target_language + def translate(self, translator_name, source_language, target_language, target_country, message): try: result = "" - source_language=translation_lang[translator_name]["source"][source_language] - target_language=translation_lang[translator_name]["target"][target_language] + source_language, target_language = self.getLanguageCode(translator_name, target_country, source_language, target_language) match translator_name: case "DeepL": result = other_web_Translator( @@ -55,16 +74,6 @@ class Translator(): if self.deepl_client is None: result = False else: - if target_language == "English": - if target_country in ["United States", "Canada", "Philippines"]: - target_language = "English American" - else: - target_language = "English British" - elif target_language == "Portuguese": - if target_country in ["Portugal"]: - target_language = "Portuguese European" - else: - target_language = "Portuguese Brazilian" result = self.deepl_client.translate_text( message, source_lang=source_language, From fad843224a1790c938a6b8f7f1e2242b687113f4 Mon Sep 17 00:00:00 2001 From: misyaguziya Date: Sun, 28 Jan 2024 22:46:15 +0900 Subject: [PATCH 3/4] =?UTF-8?q?=F0=9F=91=8D[Update]=20gitiginore=20:=20add?= =?UTF-8?q?=20*.exe?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index c6967444..75c28a41 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ logs/ weight/ .vscode error.log +*.exe From d6e05acaca22c8b159ec95db4184c6a1841c4f8e Mon Sep 17 00:00:00 2001 From: misyaguziya Date: Sun, 28 Jan 2024 22:48:57 +0900 Subject: [PATCH 4/4] =?UTF-8?q?=F0=9F=91=8D[Update]=20:=20Config=20:=20ver?= =?UTF-8?q?sion=202.1.0=20->=202.1.1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.py b/config.py index dc882684..371ec121 100644 --- a/config.py +++ b/config.py @@ -731,7 +731,7 @@ class Config: def init_config(self): # Read Only - self._VERSION = "2.1.0" + self._VERSION = "2.1.1" self._ENABLE_SPEAKER2CHATBOX = False # Speaker2Chatbox self._PATH_LOCAL = os_path.dirname(sys.argv[0]) self._PATH_CONFIG = os_path.join(self._PATH_LOCAL, "config.json")