GameSentenceMiner 2.14.1__py3-none-any.whl → 2.14.3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,12 +7,14 @@ import websockets
7
7
  from websockets import InvalidStatus
8
8
  from rapidfuzz import fuzz
9
9
 
10
+
10
11
  from GameSentenceMiner.util.db import GameLinesTable
11
12
  from GameSentenceMiner.util.gsm_utils import do_text_replacements, TEXT_REPLACEMENTS_FILE, run_new_thread
12
13
  from GameSentenceMiner.util.configuration import *
13
14
  from GameSentenceMiner.util.text_log import *
14
15
  from GameSentenceMiner import obs
15
- from GameSentenceMiner.web.texthooking_page import add_event_to_texthooker, send_word_coordinates_to_overlay, overlay_server_thread
16
+ from GameSentenceMiner.web.texthooking_page import add_event_to_texthooker, overlay_server_thread
17
+
16
18
  from GameSentenceMiner.util.get_overlay_coords import OverlayProcessor
17
19
 
18
20
 
@@ -29,8 +31,7 @@ last_clipboard = ''
29
31
 
30
32
  reconnecting = False
31
33
  websocket_connected = {}
32
-
33
- overlay_processor = OverlayProcessor()
34
+ overlay_processor = None
34
35
 
35
36
  async def monitor_clipboard():
36
37
  global current_line, last_clipboard
@@ -179,6 +180,7 @@ async def handle_new_text_event(current_clipboard, line_time=None):
179
180
 
180
181
 
181
182
  async def add_line_to_text_log(line, line_time=None):
183
+ global overlay_processor
182
184
  if get_config().general.texthook_replacement_regex:
183
185
  current_line_after_regex = re.sub(get_config().general.texthook_replacement_regex, '', line)
184
186
  else:
@@ -191,7 +193,10 @@ async def add_line_to_text_log(line, line_time=None):
191
193
  if len(get_text_log().values) > 0:
192
194
  await add_event_to_texthooker(get_text_log()[-1])
193
195
  if get_config().overlay.websocket_port and overlay_server_thread.has_clients():
194
- await overlay_processor.find_box_and_send_to_overlay(current_line_after_regex)
196
+ if not overlay_processor:
197
+ overlay_processor = OverlayProcessor()
198
+ if overlay_processor.ready:
199
+ await overlay_processor.find_box_and_send_to_overlay(current_line_after_regex)
195
200
  GameLinesTable.add_line(get_text_log()[-1])
196
201
 
197
202
 
@@ -71,7 +71,12 @@ except ImportError:
71
71
  pass
72
72
 
73
73
  try:
74
- import oneocr
74
+ try:
75
+ if os.path.exists(os.path.expanduser('~/.config/oneocr/oneocr.dll')):
76
+ import oneocr
77
+ except Exception as e:
78
+ oneocr = None
79
+ logger.warning(f'Failed to import OneOCR: {e}', exc_info=True)
75
80
  except ImportError:
76
81
  pass
77
82
 
@@ -870,6 +875,7 @@ class OneOCR:
870
875
  logger.warning('OneOCR DLLs not found, please install OwOCR Dependencies via OCR Tab in GSM.')
871
876
  else:
872
877
  try:
878
+ logger.info(f'Loading OneOCR model')
873
879
  self.model = oneocr.OcrEngine()
874
880
  except RuntimeError as e:
875
881
  logger.warning(e + ', OneOCR will not work!')
@@ -8,16 +8,24 @@ from PIL import Image
8
8
  from typing import Dict, Any, List, Tuple
9
9
 
10
10
  # Local application imports
11
- from GameSentenceMiner.util.configuration import get_config
11
+ from GameSentenceMiner.ocr.gsm_ocr_config import set_dpi_awareness
12
+ from GameSentenceMiner.util.configuration import get_config, is_windows
12
13
  from GameSentenceMiner.util.electron_config import get_ocr_language
13
14
  from GameSentenceMiner.obs import get_screenshot_PIL, logger
14
15
  from GameSentenceMiner.web.texthooking_page import send_word_coordinates_to_overlay
15
16
 
16
17
  # Conditionally import OCR engines
17
18
  try:
18
- from GameSentenceMiner.owocr.owocr.ocr import GoogleLens, OneOCR, get_regex
19
- except ImportError:
19
+ if os.path.exists(os.path.expanduser('~/.config/oneocr/oneocr.dll')):
20
+ from GameSentenceMiner.owocr.owocr.ocr import OneOCR
21
+ else:
22
+ OneOCR = None
23
+ from GameSentenceMiner.owocr.owocr.ocr import GoogleLens, get_regex
24
+ except ImportError as import_err:
25
+ GoogleLens, OneOCR, get_regex = None, None, None
26
+ except Exception as e:
20
27
  GoogleLens, OneOCR, get_regex = None, None, None
28
+ logger.error(f"Error importing OCR engines: {e}", exc_info=True)
21
29
 
22
30
  # Conditionally import screenshot library
23
31
  try:
@@ -40,19 +48,31 @@ class OverlayProcessor:
40
48
  self.oneocr = None
41
49
  self.lens = None
42
50
  self.regex = None
51
+ self.ready = False
43
52
 
44
- if self.config.overlay.websocket_port and all([GoogleLens, OneOCR, get_regex]):
45
- logger.info("Initializing OCR engines...")
46
- self.oneocr = OneOCR(lang=get_ocr_language())
47
- self.lens = GoogleLens(lang=get_ocr_language())
48
- self.ocr_language = get_ocr_language()
49
- self.regex = get_regex(self.ocr_language)
50
- logger.info("OCR engines initialized.")
51
- else:
52
- logger.warning("OCR dependencies not found or websocket port not configured. OCR functionality will be disabled.")
53
+ try:
54
+ if self.config.overlay.websocket_port and all([GoogleLens, get_regex]):
55
+ logger.info("Initializing OCR engines...")
56
+ if OneOCR:
57
+ self.oneocr = OneOCR(lang=get_ocr_language())
58
+ self.lens = GoogleLens(lang=get_ocr_language())
59
+ self.ocr_language = get_ocr_language()
60
+ self.regex = get_regex(self.ocr_language)
61
+ logger.info("OCR engines initialized.")
62
+ self.ready = True
63
+ else:
64
+ logger.warning("OCR dependencies not found or websocket port not configured. OCR functionality will be disabled.")
53
65
 
54
- if not mss:
55
- logger.warning("MSS library not found. Screenshot functionality may be limited.")
66
+ if is_windows:
67
+ set_dpi_awareness()
68
+
69
+ if not mss:
70
+ logger.warning("MSS library not found. Screenshot functionality may be limited.")
71
+ except Exception as e:
72
+ logger.error(f"Error initializing OCR engines for overlay, try installing owocr in OCR tab of GSM: {e}", exc_info=True)
73
+ self.oneocr = None
74
+ self.lens = None
75
+ self.regex = None
56
76
 
57
77
  async def find_box_and_send_to_overlay(self, sentence_to_check: str = None):
58
78
  """
@@ -124,8 +144,9 @@ class OverlayProcessor:
124
144
 
125
145
  async def _do_work(self, sentence_to_check: str = None) -> Tuple[List[Dict[str, Any]], int]:
126
146
  """The main OCR workflow."""
127
- if not self.oneocr or not self.lens:
128
- raise RuntimeError("OCR engines are not initialized. Cannot perform OCR.")
147
+ if not self.lens:
148
+ logger.error("OCR engines are not initialized. Cannot perform OCR for Overlay.")
149
+ return []
129
150
 
130
151
  # 1. Get screenshot
131
152
  full_screenshot, monitor_width, monitor_height = self._get_full_screenshot()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: GameSentenceMiner
3
- Version: 2.14.1
3
+ Version: 2.14.3
4
4
  Summary: A tool for mining sentences from games. Update: Overlay?
5
5
  Author-email: Beangate <bpwhelan95@gmail.com>
6
6
  License: MIT License
@@ -1,7 +1,7 @@
1
1
  GameSentenceMiner/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
2
  GameSentenceMiner/anki.py,sha256=mNUU0AYwsDezVug-ZXDpR71R9GGUBsmc9Gu8ftfnpf4,23078
3
3
  GameSentenceMiner/config_gui.py,sha256=dFN-2mD9JTcRhjFIjaj4bFcEmMAdjudYk_A5x9rp3_U,134126
4
- GameSentenceMiner/gametext.py,sha256=2MHOLuuXAxrhs0tkwh9JW_BYHQ7YMf-lHfO2Kl3ACDs,10244
4
+ GameSentenceMiner/gametext.py,sha256=fgBgLchezpauWELE9Y5G3kVCLfAneD0X4lJFoI3FYbs,10351
5
5
  GameSentenceMiner/gsm.py,sha256=GdqegZnKrTMVRvp43bK7oNlWj5OxLx2PNdVWyHL9Gc4,28282
6
6
  GameSentenceMiner/obs.py,sha256=LfczcmAF1G2-L7HxFAJJ-0rlCMy29WN2YUuDbeATP1g,18845
7
7
  GameSentenceMiner/vad.py,sha256=zFReBMvNEEaQ_YEozCTCaMdV-o40FwtlxYRb17cYZio,19125
@@ -28,7 +28,7 @@ GameSentenceMiner/owocr/owocr/__init__.py,sha256=87hfN5u_PbL_onLfMACbc0F5j4KyIK9
28
28
  GameSentenceMiner/owocr/owocr/__main__.py,sha256=XQaqZY99EKoCpU-gWQjNbTs7Kg17HvBVE7JY8LqIE0o,157
29
29
  GameSentenceMiner/owocr/owocr/config.py,sha256=qM7kISHdUhuygGXOxmgU6Ef2nwBShrZtdqu4InDCViE,8103
30
30
  GameSentenceMiner/owocr/owocr/lens_betterproto.py,sha256=oNoISsPilVVRBBPVDtb4-roJtAhp8ZAuFTci3TGXtMc,39141
31
- GameSentenceMiner/owocr/owocr/ocr.py,sha256=3Qux9yNVhTq5gZ31jcrVeyFvLcVZCoPc0sddGFL_DUc,68792
31
+ GameSentenceMiner/owocr/owocr/ocr.py,sha256=8DDmWC-_49I1q9uExDp2ognM7GeL6E5OYokeFDe4zFw,69070
32
32
  GameSentenceMiner/owocr/owocr/run.py,sha256=TSSZnHO_sPoTtUCsDol-v4TWPPzz_Nbf24TeBUea5I4,68498
33
33
  GameSentenceMiner/owocr/owocr/screen_coordinate_picker.py,sha256=Na6XStbQBtpQUSdbN3QhEswtKuU1JjReFk_K8t5ezQE,3395
34
34
  GameSentenceMiner/tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -40,7 +40,7 @@ GameSentenceMiner/util/configuration.py,sha256=SODstU9nrRRAmbPrubYHJuGzzuKXURNUE
40
40
  GameSentenceMiner/util/db.py,sha256=2bO0rD4i8A1hhsRBER-wgZy9IK17ibRbI8DHxdKvYsI,16598
41
41
  GameSentenceMiner/util/electron_config.py,sha256=9CA27nzEFlxezzDqOPHxeD4BdJ093AnSJ9DJTcwWPsM,8762
42
42
  GameSentenceMiner/util/ffmpeg.py,sha256=iqsdp3TbBv6KMACJxkUF3e5VWak3jHPZdIEMrUdKFtE,23073
43
- GameSentenceMiner/util/get_overlay_coords.py,sha256=GmDiIOBuZbQXwa6oh5OQHVoMQvlKA9IsSkxmSblZP4w,12357
43
+ GameSentenceMiner/util/get_overlay_coords.py,sha256=h4ofCy16bWqs7omgPqqFi7EeYMkDO8gvePULoWTGiZE,13237
44
44
  GameSentenceMiner/util/gsm_utils.py,sha256=Piwv88Q9av2LBeN7M6QDi0Mp0_R2lNbkcI6ekK5hd2o,11851
45
45
  GameSentenceMiner/util/model.py,sha256=R-_RYTYLSDNgBoVTPuPBcIHeOznIqi_vBzQ7VQ20WYk,6727
46
46
  GameSentenceMiner/util/notification.py,sha256=-qk3kTKEERzmMxx5XMh084HCyFmbfqz0XjY1hTKhCeQ,4202
@@ -69,9 +69,9 @@ GameSentenceMiner/web/templates/index.html,sha256=Gv3CJvNnhAzIVV_QxhNq4OD-pXDt1v
69
69
  GameSentenceMiner/web/templates/text_replacements.html,sha256=tV5c8mCaWSt_vKuUpbdbLAzXZ3ATZeDvQ9PnnAfqY0M,8598
70
70
  GameSentenceMiner/web/templates/utility.html,sha256=3flZinKNqUJ7pvrZk6xu__v67z44rXnaK7UTZ303R-8,16946
71
71
  GameSentenceMiner/wip/__init___.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
72
- gamesentenceminer-2.14.1.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
73
- gamesentenceminer-2.14.1.dist-info/METADATA,sha256=erBDcWHYMdtMLSIH2zQiOzC2zKIuPwne795wyg0sj3Y,1564
74
- gamesentenceminer-2.14.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
75
- gamesentenceminer-2.14.1.dist-info/entry_points.txt,sha256=2APEP25DbfjSxGeHtwBstMH8mulVhLkqF_b9bqzU6vQ,65
76
- gamesentenceminer-2.14.1.dist-info/top_level.txt,sha256=V1hUY6xVSyUEohb0uDoN4UIE6rUZ_JYx8yMyPGX4PgQ,18
77
- gamesentenceminer-2.14.1.dist-info/RECORD,,
72
+ gamesentenceminer-2.14.3.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
73
+ gamesentenceminer-2.14.3.dist-info/METADATA,sha256=iOnuch0VMzYmppjjW9VocRCN2bTmqwrCtAt8AJa5rws,1564
74
+ gamesentenceminer-2.14.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
75
+ gamesentenceminer-2.14.3.dist-info/entry_points.txt,sha256=2APEP25DbfjSxGeHtwBstMH8mulVhLkqF_b9bqzU6vQ,65
76
+ gamesentenceminer-2.14.3.dist-info/top_level.txt,sha256=V1hUY6xVSyUEohb0uDoN4UIE6rUZ_JYx8yMyPGX4PgQ,18
77
+ gamesentenceminer-2.14.3.dist-info/RECORD,,