Skip to content

Commit

Permalink
fix font
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderLJX committed Aug 23, 2023
1 parent eb8848f commit 5f937cb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion run.bat
Original file line number Diff line number Diff line change
@@ -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
Expand Down
11 changes: 11 additions & 0 deletions test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import sys
import time
import tesserocr
from manga_ocr import MangaOcr
from PyQt5.QtWidgets import QApplication, QMainWindow, QRubberBand
Expand Down Expand Up @@ -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():
Expand Down

0 comments on commit 5f937cb

Please sign in to comment.