From 5f937cbe1387202dfb23b670cf9440944a56b7c3 Mon Sep 17 00:00:00 2001 From: Alexander Date: Wed, 23 Aug 2023 21:07:13 +0800 Subject: [PATCH] fix font --- run.bat | 2 +- test.py | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/run.bat b/run.bat index 2e783da..fa7f268 100644 --- a/run.bat +++ b/run.bat @@ -1,7 +1,7 @@ @echo off set env_name=sniptranslate -set arguments=--translate --console_font_size 11 --chatgpt_translation_length long --tts_untranslated --proxy_timeout 10000 --use_manga_ocr +set arguments=--translate --console_font_size 12 --chatgpt_translation_length long --tts_untranslated --proxy_timeout 20000 --use_manga_ocr REM Set the title back to snip-translate title snip-translate diff --git a/test.py b/test.py index b7476df..94ddf5d 100644 --- a/test.py +++ b/test.py @@ -1,4 +1,5 @@ import sys +import time import tesserocr from manga_ocr import MangaOcr from PyQt5.QtWidgets import QApplication, QMainWindow, QRubberBand @@ -237,6 +238,16 @@ def run(self): translate_function = getattr(self.snipping_tool, self.translate_function_name) translation = translate_function(self.text) # tts + # if http error retry + if translation == "ChatGPT: HTTP error occurred": + # start timer based on proxy timeout + start_time = time.time() + while translation == "ChatGPT: HTTP error occurred": + # if timeout reached, break + if time.time() - start_time > self.snipping_tool.main_window.proxy_timeout.value()/1000.0: + break + print("HTTP error occurred, retrying...") + translation = translate_function(self.text) if translation not in ["", "No text detected", "HTTP error occurred"]: if translation.split(":")[0] == "Google Translate": if self.snipping_tool.main_window.tts_translated_checkbox.isChecked():