GameSentenceMiner 2.8.46__py3-none-any.whl → 2.8.47__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.
@@ -71,9 +71,5 @@ class OCRConfig:
71
71
 
72
72
  # try w10+, fall back to w8.1+
73
73
  def set_dpi_awareness():
74
- try:
75
- awareness_context = -4
76
- ctypes.windll.user32.SetProcessDpiAwarenessContext(awareness_context)
77
- except AttributeError:
78
- per_monitor_awareness = 2
79
- ctypes.windll.shcore.SetProcessDpiAwareness(per_monitor_awareness)
74
+ per_monitor_awareness = 2
75
+ ctypes.windll.shcore.SetProcessDpiAwareness(per_monitor_awareness)
@@ -13,6 +13,7 @@ from urllib.parse import urlparse, parse_qs
13
13
  import jaconv
14
14
  import numpy as np
15
15
  from PIL import Image
16
+ from google.generativeai import GenerationConfig
16
17
  from loguru import logger
17
18
  import requests
18
19
 
@@ -1003,7 +1004,10 @@ class GeminiOCR:
1003
1004
  logger.warning('Gemini API key not provided, GeminiOCR will not work!')
1004
1005
  else:
1005
1006
  genai.configure(api_key=self.api_key)
1006
- self.model = genai.GenerativeModel(config['model'])
1007
+ self.model = genai.GenerativeModel(config['model'], generation_config=GenerationConfig(
1008
+ temperature=0.0,
1009
+ max_output_tokens=300
1010
+ ))
1007
1011
  self.available = True
1008
1012
  logger.info('Gemini (using google-generativeai) ready')
1009
1013
  except KeyError:
@@ -1011,19 +1015,13 @@ class GeminiOCR:
1011
1015
  except Exception as e:
1012
1016
  logger.error(f'Error configuring google-generativeai: {e}')
1013
1017
 
1014
- def __call__(self, img_or_path):
1018
+ def __call__(self, img):
1015
1019
  if not self.available:
1016
1020
  return (False, 'GeminiOCR is not available due to missing API key or configuration error.')
1017
1021
 
1018
1022
  try:
1023
+ img = input_to_pil_image(img)
1019
1024
  import google.generativeai as genai
1020
- if isinstance(img_or_path, str) or isinstance(img_or_path, Path):
1021
- img = Image.open(img_or_path)
1022
- elif isinstance(img_or_path, Image.Image):
1023
- img = img_or_path
1024
- else:
1025
- raise ValueError(f'img_or_path must be a path or PIL.Image, instead got: {img_or_path}')
1026
-
1027
1025
  img_bytes = self._preprocess(img)
1028
1026
  if not img_bytes:
1029
1027
  return (False, 'Error processing image for Gemini.')
@@ -1050,7 +1048,7 @@ class GeminiOCR:
1050
1048
  return (True, text_output)
1051
1049
 
1052
1050
  except FileNotFoundError:
1053
- return (False, f'File not found: {img_or_path}')
1051
+ return (False, f'File not found: {img}')
1054
1052
  except Exception as e:
1055
1053
  return (False, f'Gemini API request failed: {e}')
1056
1054
 
@@ -1079,17 +1077,12 @@ class GroqOCR:
1079
1077
  except Exception as e:
1080
1078
  logger.error(f'Error initializing Groq client: {e}')
1081
1079
 
1082
- def __call__(self, img_or_path):
1080
+ def __call__(self, img):
1083
1081
  if not self.available:
1084
1082
  return (False, 'GroqOCR is not available due to missing API key or configuration error.')
1085
1083
 
1086
1084
  try:
1087
- if isinstance(img_or_path, str) or isinstance(img_or_path, Path):
1088
- img = Image.open(img_or_path).convert("RGB")
1089
- elif isinstance(img_or_path, Image.Image):
1090
- img = img_or_path.convert("RGB")
1091
- else:
1092
- raise ValueError(f'img_or_path must be a path or PIL.Image, instead got: {img_or_path}')
1085
+ img = input_to_pil_image(img)
1093
1086
 
1094
1087
  img_base64 = self._preprocess(img)
1095
1088
  if not img_base64:
@@ -1116,7 +1109,8 @@ class GroqOCR:
1116
1109
  ],
1117
1110
  }
1118
1111
  ],
1119
- max_tokens=300
1112
+ max_tokens=300,
1113
+ temperature=0.0
1120
1114
  )
1121
1115
 
1122
1116
  if response.choices and response.choices[0].message.content:
@@ -1126,7 +1120,7 @@ class GroqOCR:
1126
1120
  return (True, "")
1127
1121
 
1128
1122
  except FileNotFoundError:
1129
- return (False, f'File not found: {img_or_path}')
1123
+ return (False, f'File not found: {img}')
1130
1124
  except Exception as e:
1131
1125
  return (False, f'Groq API request failed: {e}')
1132
1126
 
@@ -1,3 +1,5 @@
1
+ from ...ocr.gsm_ocr_config import set_dpi_awareness
2
+
1
3
  try:
2
4
  import win32gui
3
5
  import win32ui
@@ -520,7 +522,7 @@ class ScreenshotClass:
520
522
  if not self.window_handle:
521
523
  raise ValueError(area_invalid_error)
522
524
 
523
- self.set_dpi_awareness()
525
+ set_dpi_awareness()
524
526
 
525
527
  self.windows_window_tracker_instance = threading.Thread(target=self.windows_window_tracker)
526
528
  self.windows_window_tracker_instance.start()
@@ -534,25 +536,6 @@ class ScreenshotClass:
534
536
  elif self.windows_window_tracker_instance:
535
537
  self.windows_window_tracker_instance.join()
536
538
 
537
- @staticmethod
538
- def set_dpi_awareness():
539
- try:
540
- # Try Windows 10+ API first
541
- awareness_context = -4
542
- success = ctypes.windll.user32.SetProcessDpiAwarenessContext(awareness_context)
543
- if success:
544
- print("Set DPI awareness: PER_MONITOR_AWARE_V2")
545
- else:
546
- print("Failed to set DPI awareness context (-4); falling back.")
547
- except AttributeError:
548
- # Fallback for older Windows versions (8.1+)
549
- try:
550
- per_monitor_awareness = 2
551
- ctypes.windll.shcore.SetProcessDpiAwareness(per_monitor_awareness)
552
- print("Set DPI awareness: PER_MONITOR_DPI_AWARE")
553
- except Exception as e:
554
- print("Could not set DPI awareness:", e)
555
-
556
539
  def get_windows_window_handle(self, window_title):
557
540
  def callback(hwnd, window_title_part):
558
541
  window_title = win32gui.GetWindowText(hwnd)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: GameSentenceMiner
3
- Version: 2.8.46
3
+ Version: 2.8.47
4
4
  Summary: A tool for mining sentences from games. Update: Multi-Line Mining! Fixed!
5
5
  Author-email: Beangate <bpwhelan95@gmail.com>
6
6
  License: MIT License
@@ -24,7 +24,7 @@ GameSentenceMiner/downloader/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NM
24
24
  GameSentenceMiner/downloader/download_tools.py,sha256=aRfpCqEmKUFRVsGipwY-7PhY6AeWiFJanW4ZCB9e2iE,8124
25
25
  GameSentenceMiner/downloader/oneocr_dl.py,sha256=o3ANp5IodEQoQ8GPcJdg9Y8JzA_lictwnebFPwwUZVk,10144
26
26
  GameSentenceMiner/ocr/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
27
- GameSentenceMiner/ocr/gsm_ocr_config.py,sha256=WFTGg2J8FAqoILVbJaMt5XWhF-btXeDnj38Iuz-kf8k,2410
27
+ GameSentenceMiner/ocr/gsm_ocr_config.py,sha256=fEQ2o2NXksGRHpueO8c4TfAp75GEdAtAr1ngTFOsdpg,2257
28
28
  GameSentenceMiner/ocr/ocrconfig.py,sha256=_tY8mjnzHMJrLS8E5pHqYXZjMuLoGKYgJwdhYgN-ny4,6466
29
29
  GameSentenceMiner/ocr/owocr_area_selector.py,sha256=Q8ETMHL7BKMA1mbtjrntDLyqCQB0lZ5T4RCZsodjH7Y,47186
30
30
  GameSentenceMiner/ocr/owocr_helper.py,sha256=mcmljTQYfRHyoqtCVOHjyVAEGWwEkdUAYXY3Z85J4eg,16415
@@ -32,8 +32,8 @@ GameSentenceMiner/owocr/owocr/__init__.py,sha256=opjBOyGGyEqZCE6YdZPnyt7nVfiwyEL
32
32
  GameSentenceMiner/owocr/owocr/__main__.py,sha256=XQaqZY99EKoCpU-gWQjNbTs7Kg17HvBVE7JY8LqIE0o,157
33
33
  GameSentenceMiner/owocr/owocr/config.py,sha256=qM7kISHdUhuygGXOxmgU6Ef2nwBShrZtdqu4InDCViE,8103
34
34
  GameSentenceMiner/owocr/owocr/lens_betterproto.py,sha256=oNoISsPilVVRBBPVDtb4-roJtAhp8ZAuFTci3TGXtMc,39141
35
- GameSentenceMiner/owocr/owocr/ocr.py,sha256=dPnDmtG-I24kcfxC3iudeRIVgGhLmiWMGyRiMANcYsA,41573
36
- GameSentenceMiner/owocr/owocr/run.py,sha256=MekuzH78OxSa2a79YpXdgJikrRh01oxk3Ydre7bxjTE,54942
35
+ GameSentenceMiner/owocr/owocr/ocr.py,sha256=6P6zSoykrsJnYqngQI9ULc98zXeTMJCfAoCMedtphzw,41132
36
+ GameSentenceMiner/owocr/owocr/run.py,sha256=oESHucfOXO_HXCjmbhEeRQ6CKeIo-sRN877EjdoKCgA,54169
37
37
  GameSentenceMiner/owocr/owocr/screen_coordinate_picker.py,sha256=Na6XStbQBtpQUSdbN3QhEswtKuU1JjReFk_K8t5ezQE,3395
38
38
  GameSentenceMiner/vad/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
39
39
  GameSentenceMiner/vad/result.py,sha256=C08HsYH4qVjTRh_dvrWrskmXHJ950w0GWxPjGx_BfGY,275
@@ -54,9 +54,9 @@ GameSentenceMiner/web/static/web-app-manifest-512x512.png,sha256=wyqgCWCrLEUxSRX
54
54
  GameSentenceMiner/web/templates/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
55
55
  GameSentenceMiner/web/templates/text_replacements.html,sha256=tV5c8mCaWSt_vKuUpbdbLAzXZ3ATZeDvQ9PnnAfqY0M,8598
56
56
  GameSentenceMiner/web/templates/utility.html,sha256=P659ZU2j7tcbJ5xPO3p7E_SQpkp3CrrFtSvvXJNNuLI,16330
57
- gamesentenceminer-2.8.46.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
58
- gamesentenceminer-2.8.46.dist-info/METADATA,sha256=GdOQ39XqFUzkGREBUaVLBWiBpP6Oak-SOzh-ur_r0tA,7218
59
- gamesentenceminer-2.8.46.dist-info/WHEEL,sha256=Nw36Djuh_5VDukK0H78QzOX-_FQEo6V37m3nkm96gtU,91
60
- gamesentenceminer-2.8.46.dist-info/entry_points.txt,sha256=2APEP25DbfjSxGeHtwBstMH8mulVhLkqF_b9bqzU6vQ,65
61
- gamesentenceminer-2.8.46.dist-info/top_level.txt,sha256=V1hUY6xVSyUEohb0uDoN4UIE6rUZ_JYx8yMyPGX4PgQ,18
62
- gamesentenceminer-2.8.46.dist-info/RECORD,,
57
+ gamesentenceminer-2.8.47.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
58
+ gamesentenceminer-2.8.47.dist-info/METADATA,sha256=OijMxmkfSyISA99v3vVlf6FVJKzeD8pn65NlW2tz0gk,7218
59
+ gamesentenceminer-2.8.47.dist-info/WHEEL,sha256=Nw36Djuh_5VDukK0H78QzOX-_FQEo6V37m3nkm96gtU,91
60
+ gamesentenceminer-2.8.47.dist-info/entry_points.txt,sha256=2APEP25DbfjSxGeHtwBstMH8mulVhLkqF_b9bqzU6vQ,65
61
+ gamesentenceminer-2.8.47.dist-info/top_level.txt,sha256=V1hUY6xVSyUEohb0uDoN4UIE6rUZ_JYx8yMyPGX4PgQ,18
62
+ gamesentenceminer-2.8.47.dist-info/RECORD,,