GameSentenceMiner 2.14.9__py3-none-any.whl → 2.14.10__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.
- GameSentenceMiner/ai/__init__.py +0 -0
- GameSentenceMiner/ai/ai_prompting.py +473 -0
- GameSentenceMiner/ocr/__init__.py +0 -0
- GameSentenceMiner/ocr/gsm_ocr_config.py +174 -0
- GameSentenceMiner/ocr/ocrconfig.py +129 -0
- GameSentenceMiner/ocr/owocr_area_selector.py +629 -0
- GameSentenceMiner/ocr/owocr_helper.py +638 -0
- GameSentenceMiner/ocr/ss_picker.py +140 -0
- GameSentenceMiner/owocr/owocr/__init__.py +1 -0
- GameSentenceMiner/owocr/owocr/__main__.py +9 -0
- GameSentenceMiner/owocr/owocr/config.py +148 -0
- GameSentenceMiner/owocr/owocr/lens_betterproto.py +1238 -0
- GameSentenceMiner/owocr/owocr/ocr.py +1690 -0
- GameSentenceMiner/owocr/owocr/run.py +1818 -0
- GameSentenceMiner/owocr/owocr/screen_coordinate_picker.py +109 -0
- GameSentenceMiner/tools/__init__.py +0 -0
- GameSentenceMiner/tools/audio_offset_selector.py +215 -0
- GameSentenceMiner/tools/ss_selector.py +135 -0
- GameSentenceMiner/tools/window_transparency.py +214 -0
- GameSentenceMiner/util/__init__.py +0 -0
- GameSentenceMiner/util/communication/__init__.py +22 -0
- GameSentenceMiner/util/communication/send.py +7 -0
- GameSentenceMiner/util/communication/websocket.py +94 -0
- GameSentenceMiner/util/configuration.py +1199 -0
- GameSentenceMiner/util/db.py +408 -0
- GameSentenceMiner/util/downloader/Untitled_json.py +472 -0
- GameSentenceMiner/util/downloader/__init__.py +0 -0
- GameSentenceMiner/util/downloader/download_tools.py +194 -0
- GameSentenceMiner/util/downloader/oneocr_dl.py +250 -0
- GameSentenceMiner/util/electron_config.py +259 -0
- GameSentenceMiner/util/ffmpeg.py +571 -0
- GameSentenceMiner/util/get_overlay_coords.py +366 -0
- GameSentenceMiner/util/gsm_utils.py +323 -0
- GameSentenceMiner/util/model.py +206 -0
- GameSentenceMiner/util/notification.py +157 -0
- GameSentenceMiner/util/text_log.py +214 -0
- GameSentenceMiner/util/win10toast/__init__.py +154 -0
- GameSentenceMiner/util/win10toast/__main__.py +22 -0
- GameSentenceMiner/web/__init__.py +0 -0
- GameSentenceMiner/web/service.py +132 -0
- GameSentenceMiner/web/static/__init__.py +0 -0
- GameSentenceMiner/web/static/apple-touch-icon.png +0 -0
- GameSentenceMiner/web/static/favicon-96x96.png +0 -0
- GameSentenceMiner/web/static/favicon.ico +0 -0
- GameSentenceMiner/web/static/favicon.svg +3 -0
- GameSentenceMiner/web/static/site.webmanifest +21 -0
- GameSentenceMiner/web/static/style.css +292 -0
- GameSentenceMiner/web/static/web-app-manifest-192x192.png +0 -0
- GameSentenceMiner/web/static/web-app-manifest-512x512.png +0 -0
- GameSentenceMiner/web/templates/__init__.py +0 -0
- GameSentenceMiner/web/templates/index.html +50 -0
- GameSentenceMiner/web/templates/text_replacements.html +238 -0
- GameSentenceMiner/web/templates/utility.html +483 -0
- GameSentenceMiner/web/texthooking_page.py +584 -0
- GameSentenceMiner/wip/__init___.py +0 -0
- {gamesentenceminer-2.14.9.dist-info → gamesentenceminer-2.14.10.dist-info}/METADATA +1 -1
- gamesentenceminer-2.14.10.dist-info/RECORD +79 -0
- gamesentenceminer-2.14.9.dist-info/RECORD +0 -24
- {gamesentenceminer-2.14.9.dist-info → gamesentenceminer-2.14.10.dist-info}/WHEEL +0 -0
- {gamesentenceminer-2.14.9.dist-info → gamesentenceminer-2.14.10.dist-info}/entry_points.txt +0 -0
- {gamesentenceminer-2.14.9.dist-info → gamesentenceminer-2.14.10.dist-info}/licenses/LICENSE +0 -0
- {gamesentenceminer-2.14.9.dist-info → gamesentenceminer-2.14.10.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,129 @@
|
|
1
|
+
import configparser
|
2
|
+
import os
|
3
|
+
|
4
|
+
class OCRConfig:
|
5
|
+
def __init__(self, config_file=os.path.expanduser("~/.config/owocr_config.ini")):
|
6
|
+
self.config_file = config_file
|
7
|
+
self.config = configparser.ConfigParser(allow_no_value=True)
|
8
|
+
self.raw_config = {} # Store the raw lines of the config file
|
9
|
+
self.load_config()
|
10
|
+
|
11
|
+
def load_config(self):
|
12
|
+
if os.path.exists(self.config_file):
|
13
|
+
self.raw_config = self._read_config_with_comments()
|
14
|
+
self.config.read_dict(self._parse_config_to_dict())
|
15
|
+
else:
|
16
|
+
self.create_default_config()
|
17
|
+
|
18
|
+
def create_default_config(self):
|
19
|
+
self.raw_config = {
|
20
|
+
"general": [
|
21
|
+
";engines = avision,alivetext,bing,glens,glensweb,gvision,azure,mangaocr,winrtocr,oneocr,easyocr,rapidocr,ocrspace",
|
22
|
+
";engine = glens",
|
23
|
+
"read_from = screencapture",
|
24
|
+
"write_to = websocket",
|
25
|
+
";note: this specifies an amount of seconds to wait for auto pausing the program after a successful text recognition. Will be ignored when reading with screen capture. 0 to disable.",
|
26
|
+
";auto_pause = 0",
|
27
|
+
";pause_at_startup = False",
|
28
|
+
";logger_format = <green>{time:HH:mm:ss.SSS}</green> | <level>{message}</level>",
|
29
|
+
";engine_color = cyan",
|
30
|
+
"websocket_port = 7331",
|
31
|
+
";delay_secs = 0.5",
|
32
|
+
";notifications = False",
|
33
|
+
";ignore_flag = False",
|
34
|
+
";delete_images = False",
|
35
|
+
";note: this specifies a combo to wait on for pausing the program. As an example: <ctrl>+<shift>+p. The list of keys can be found here: https://pynput.readthedocs.io/en/latest/keyboard.html#pynput.keyboard.Key",
|
36
|
+
";combo_pause = <ctrl>+<shift>+p",
|
37
|
+
";note: this specifies a combo to wait on for switching the OCR engine. As an example: <ctrl>+<shift>+a. To be used with combo_pause. The list of keys can be found here: https://pynput.readthedocs.io/en/latest/keyboard.html#pynput.keyboard.Key",
|
38
|
+
";combo_engine_switch = <ctrl>+<shift>+a",
|
39
|
+
";note: screen_capture_area can be empty for the coordinate picker, \"screen_N\" (where N is the screen number starting from 1) for an entire screen, have a manual set of coordinates (x,y,width,height) or a window name (the first matching window title will be used).",
|
40
|
+
";screen_capture_area = ",
|
41
|
+
";screen_capture_area = screen_1",
|
42
|
+
";screen_capture_area = 400,200,1500,600",
|
43
|
+
";screen_capture_area = OBS",
|
44
|
+
";note: if screen_capture_area is a window name, this can be changed to capture inactive windows too.",
|
45
|
+
";screen_capture_only_active_windows = True",
|
46
|
+
";screen_capture_delay_secs = 3",
|
47
|
+
";note: this specifies a combo to wait on for taking a screenshot instead of using the delay. As an example: <ctrl>+<shift>+s. The list of keys can be found here: https://pynput.readthedocs.io/en/latest/keyboard.html#pynput.keyboard.Key",
|
48
|
+
";screen_capture_combo = <ctrl>+<shift>+s",
|
49
|
+
],
|
50
|
+
"winrtocr": [";url = http://aaa.xxx.yyy.zzz:8000"],
|
51
|
+
"oneocr": [";url = http://aaa.xxx.yyy.zzz:8001"],
|
52
|
+
"azure": [";api_key = api_key_here", ";endpoint = https://YOURPROJECT.cognitiveservices.azure.com/"],
|
53
|
+
"mangaocr": ["pretrained_model_name_or_path = kha-white/manga-ocr-base", "force_cpu = False"],
|
54
|
+
"easyocr": ["gpu = True"],
|
55
|
+
"ocrspace": [";api_key = api_key_here"],
|
56
|
+
}
|
57
|
+
self.config.read_dict(self._parse_config_to_dict())
|
58
|
+
self.save_config()
|
59
|
+
|
60
|
+
def _read_config_with_comments(self):
|
61
|
+
with open(self.config_file, "r") as f:
|
62
|
+
lines = f.readlines()
|
63
|
+
config_data = {}
|
64
|
+
current_section = None
|
65
|
+
for line in lines:
|
66
|
+
line = line.strip()
|
67
|
+
if line.startswith("[") and line.endswith("]"):
|
68
|
+
current_section = line[1:-1]
|
69
|
+
config_data[current_section] = []
|
70
|
+
elif current_section is not None:
|
71
|
+
config_data[current_section].append(line)
|
72
|
+
return config_data
|
73
|
+
|
74
|
+
def _parse_config_to_dict(self):
|
75
|
+
parsed_config = {}
|
76
|
+
for section, lines in self.raw_config.items():
|
77
|
+
parsed_config[section] = {}
|
78
|
+
for line in lines:
|
79
|
+
if "=" in line and not line.startswith(";"):
|
80
|
+
key, value = line.split("=", 1)
|
81
|
+
parsed_config[section][key.strip()] = value.strip()
|
82
|
+
return parsed_config
|
83
|
+
|
84
|
+
def save_config(self):
|
85
|
+
with open(self.config_file, "w") as f:
|
86
|
+
for section, lines in self.raw_config.items():
|
87
|
+
f.write(f"[{section}]\n")
|
88
|
+
for line in lines:
|
89
|
+
f.write(f"{line}\n")
|
90
|
+
|
91
|
+
def get_value(self, section, key):
|
92
|
+
if section in self.config and key in self.config[section]:
|
93
|
+
return self.config[section][key]
|
94
|
+
return None
|
95
|
+
|
96
|
+
def set_value(self, section, key, value):
|
97
|
+
if section not in self.config:
|
98
|
+
self.raw_config[section] = [] #add section if it does not exist.
|
99
|
+
if section not in self.config:
|
100
|
+
self.config[section] = {}
|
101
|
+
self.config[section][key] = str(value)
|
102
|
+
|
103
|
+
# Update the raw config to keep comments
|
104
|
+
found = False
|
105
|
+
for i, line in enumerate(self.raw_config[section]):
|
106
|
+
if line.startswith(key + " ="):
|
107
|
+
self.raw_config[section][i] = f"{key} = {value}"
|
108
|
+
found = True
|
109
|
+
break
|
110
|
+
if not found:
|
111
|
+
self.raw_config[section].append(f"{key} = {value}")
|
112
|
+
|
113
|
+
self.save_config()
|
114
|
+
|
115
|
+
def get_section(self, section):
|
116
|
+
if section in self.config:
|
117
|
+
return dict(self.config[section])
|
118
|
+
return None
|
119
|
+
|
120
|
+
def set_screen_capture_area(self, screen_capture_data):
|
121
|
+
if not isinstance(screen_capture_data, dict) or "coordinates" not in screen_capture_data:
|
122
|
+
raise ValueError("Invalid screen capture data format.")
|
123
|
+
|
124
|
+
coordinates = screen_capture_data["coordinates"]
|
125
|
+
if len(coordinates) != 4:
|
126
|
+
raise ValueError("Coordinates must contain four values: x, y, width, height.")
|
127
|
+
|
128
|
+
x, y, width, height = coordinates
|
129
|
+
self.set_value("general", "screen_capture_area", f"{x},{y},{width},{height}")
|