GameSentenceMiner 2.17.0__tar.gz → 2.17.1__tar.gz

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.
Files changed (103) hide show
  1. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/GameSentenceMiner/anki.py +6 -2
  2. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/GameSentenceMiner/config_gui.py +7 -1
  3. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/GameSentenceMiner/gametext.py +4 -3
  4. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/GameSentenceMiner/gsm.py +11 -10
  5. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/GameSentenceMiner/obs.py +13 -5
  6. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/GameSentenceMiner/ocr/owocr_helper.py +10 -7
  7. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/GameSentenceMiner/owocr/owocr/run.py +9 -3
  8. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/GameSentenceMiner/util/ffmpeg.py +5 -2
  9. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/GameSentenceMiner/vad.py +5 -2
  10. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/GameSentenceMiner.egg-info/PKG-INFO +1 -1
  11. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/PKG-INFO +1 -1
  12. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/pyproject.toml +3 -3
  13. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/GameSentenceMiner/__init__.py +0 -0
  14. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/GameSentenceMiner/ai/__init__.py +0 -0
  15. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/GameSentenceMiner/ai/ai_prompting.py +0 -0
  16. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/GameSentenceMiner/assets/__init__.py +0 -0
  17. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/GameSentenceMiner/assets/icon.png +0 -0
  18. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/GameSentenceMiner/assets/icon128.png +0 -0
  19. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/GameSentenceMiner/assets/icon256.png +0 -0
  20. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/GameSentenceMiner/assets/icon32.png +0 -0
  21. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/GameSentenceMiner/assets/icon512.png +0 -0
  22. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/GameSentenceMiner/assets/icon64.png +0 -0
  23. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/GameSentenceMiner/assets/pickaxe.png +0 -0
  24. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/GameSentenceMiner/locales/en_us.json +0 -0
  25. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/GameSentenceMiner/locales/ja_jp.json +0 -0
  26. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/GameSentenceMiner/locales/zh_cn.json +0 -0
  27. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/GameSentenceMiner/ocr/__init__.py +0 -0
  28. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/GameSentenceMiner/ocr/gsm_ocr_config.py +0 -0
  29. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/GameSentenceMiner/ocr/ocrconfig.py +0 -0
  30. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/GameSentenceMiner/ocr/owocr_area_selector.py +0 -0
  31. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/GameSentenceMiner/ocr/ss_picker.py +0 -0
  32. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/GameSentenceMiner/owocr/owocr/__init__.py +0 -0
  33. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/GameSentenceMiner/owocr/owocr/__main__.py +0 -0
  34. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/GameSentenceMiner/owocr/owocr/config.py +0 -0
  35. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/GameSentenceMiner/owocr/owocr/lens_betterproto.py +0 -0
  36. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/GameSentenceMiner/owocr/owocr/ocr.py +0 -0
  37. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/GameSentenceMiner/owocr/owocr/screen_coordinate_picker.py +0 -0
  38. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/GameSentenceMiner/tools/__init__.py +0 -0
  39. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/GameSentenceMiner/tools/audio_offset_selector.py +0 -0
  40. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/GameSentenceMiner/tools/furigana_filter_preview.py +0 -0
  41. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/GameSentenceMiner/tools/ss_selector.py +0 -0
  42. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/GameSentenceMiner/tools/window_transparency.py +0 -0
  43. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/GameSentenceMiner/util/__init__.py +0 -0
  44. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/GameSentenceMiner/util/communication/__init__.py +0 -0
  45. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/GameSentenceMiner/util/communication/send.py +0 -0
  46. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/GameSentenceMiner/util/communication/websocket.py +0 -0
  47. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/GameSentenceMiner/util/configuration.py +0 -0
  48. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/GameSentenceMiner/util/db.py +0 -0
  49. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/GameSentenceMiner/util/downloader/Untitled_json.py +0 -0
  50. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/GameSentenceMiner/util/downloader/__init__.py +0 -0
  51. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/GameSentenceMiner/util/downloader/download_tools.py +0 -0
  52. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/GameSentenceMiner/util/downloader/oneocr_dl.py +0 -0
  53. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/GameSentenceMiner/util/electron_config.py +0 -0
  54. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/GameSentenceMiner/util/get_overlay_coords.py +0 -0
  55. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/GameSentenceMiner/util/gsm_utils.py +0 -0
  56. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/GameSentenceMiner/util/model.py +0 -0
  57. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/GameSentenceMiner/util/notification.py +0 -0
  58. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/GameSentenceMiner/util/text_log.py +0 -0
  59. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/GameSentenceMiner/util/win10toast/__init__.py +0 -0
  60. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/GameSentenceMiner/util/win10toast/__main__.py +0 -0
  61. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/GameSentenceMiner/web/__init__.py +0 -0
  62. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/GameSentenceMiner/web/database_api.py +0 -0
  63. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/GameSentenceMiner/web/events.py +0 -0
  64. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/GameSentenceMiner/web/gsm_websocket.py +0 -0
  65. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/GameSentenceMiner/web/service.py +0 -0
  66. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/GameSentenceMiner/web/static/__init__.py +0 -0
  67. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/GameSentenceMiner/web/static/apple-touch-icon.png +0 -0
  68. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/GameSentenceMiner/web/static/css/kanji-grid.css +0 -0
  69. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/GameSentenceMiner/web/static/css/search.css +0 -0
  70. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/GameSentenceMiner/web/static/css/shared.css +0 -0
  71. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/GameSentenceMiner/web/static/css/stats.css +0 -0
  72. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/GameSentenceMiner/web/static/favicon-96x96.png +0 -0
  73. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/GameSentenceMiner/web/static/favicon.ico +0 -0
  74. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/GameSentenceMiner/web/static/favicon.svg +0 -0
  75. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/GameSentenceMiner/web/static/js/anki_stats.js +0 -0
  76. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/GameSentenceMiner/web/static/js/database.js +0 -0
  77. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/GameSentenceMiner/web/static/js/kanji-grid.js +0 -0
  78. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/GameSentenceMiner/web/static/js/search.js +0 -0
  79. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/GameSentenceMiner/web/static/js/shared.js +0 -0
  80. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/GameSentenceMiner/web/static/js/stats.js +0 -0
  81. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/GameSentenceMiner/web/static/site.webmanifest +0 -0
  82. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/GameSentenceMiner/web/static/style.css +0 -0
  83. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/GameSentenceMiner/web/static/web-app-manifest-192x192.png +0 -0
  84. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/GameSentenceMiner/web/static/web-app-manifest-512x512.png +0 -0
  85. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/GameSentenceMiner/web/stats.py +0 -0
  86. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/GameSentenceMiner/web/templates/anki_stats.html +0 -0
  87. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/GameSentenceMiner/web/templates/components/navigation.html +0 -0
  88. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/GameSentenceMiner/web/templates/components/theme-styles.html +0 -0
  89. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/GameSentenceMiner/web/templates/database.html +0 -0
  90. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/GameSentenceMiner/web/templates/index.html +0 -0
  91. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/GameSentenceMiner/web/templates/search.html +0 -0
  92. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/GameSentenceMiner/web/templates/stats.html +0 -0
  93. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/GameSentenceMiner/web/templates/utility.html +0 -0
  94. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/GameSentenceMiner/web/texthooking_page.py +0 -0
  95. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/GameSentenceMiner/wip/__init___.py +0 -0
  96. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/GameSentenceMiner.egg-info/SOURCES.txt +0 -0
  97. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/GameSentenceMiner.egg-info/dependency_links.txt +0 -0
  98. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/GameSentenceMiner.egg-info/entry_points.txt +0 -0
  99. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/GameSentenceMiner.egg-info/requires.txt +0 -0
  100. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/GameSentenceMiner.egg-info/top_level.txt +0 -0
  101. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/LICENSE +0 -0
  102. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/README.md +0 -0
  103. {gamesentenceminer-2.17.0 → gamesentenceminer-2.17.1}/setup.cfg +0 -0
@@ -1,4 +1,8 @@
1
1
  import copy
2
+ import json
3
+ import os
4
+ import shutil
5
+ import threading
2
6
  from pathlib import Path
3
7
  import queue
4
8
  import time
@@ -15,8 +19,8 @@ from GameSentenceMiner.util.db import GameLinesTable
15
19
  from GameSentenceMiner.util.gsm_utils import make_unique, sanitize_filename, wait_for_stable_file, remove_html_and_cloze_tags, combine_dialogue, \
16
20
  run_new_thread, open_audio_in_external
17
21
  from GameSentenceMiner.util import ffmpeg, notification
18
- from GameSentenceMiner.util.configuration import *
19
- from GameSentenceMiner.util.configuration import get_config
22
+ from GameSentenceMiner.util.configuration import get_config, AnkiUpdateResult, logger, anki_results, gsm_status, \
23
+ gsm_state
20
24
  from GameSentenceMiner.util.model import AnkiCard
21
25
  from GameSentenceMiner.util.text_log import get_all_lines, get_text_event, get_mined_line, lines_match
22
26
  from GameSentenceMiner.obs import get_current_game
@@ -1,7 +1,9 @@
1
1
  import asyncio
2
2
  import copy
3
3
  import json
4
+ import os
4
5
  import subprocess
6
+ import sys
5
7
  import time
6
8
  import tkinter as tk
7
9
  from tkinter import filedialog, messagebox, simpledialog, scrolledtext, font
@@ -12,7 +14,11 @@ import ttkbootstrap as ttk
12
14
  from GameSentenceMiner import obs
13
15
  from GameSentenceMiner.util import configuration
14
16
  from GameSentenceMiner.util.communication.send import send_restart_signal
15
- from GameSentenceMiner.util.configuration import *
17
+ from GameSentenceMiner.util.configuration import Config, Locale, logger, CommonLanguages, ProfileConfig, General, Paths, \
18
+ Anki, Features, Screenshot, Audio, OBS, Hotkeys, VAD, Overlay, Ai, Advanced, OverlayEngine, get_app_directory, \
19
+ get_config, is_beangate, AVAILABLE_LANGUAGES, WHSIPER_LARGE, WHISPER_TINY, WHISPER_BASE, WHISPER_SMALL, \
20
+ WHISPER_MEDIUM, WHISPER_TURBO, SILERO, WHISPER, OFF, gsm_state, DEFAULT_CONFIG, get_latest_version, \
21
+ get_current_version, AI_GEMINI, AI_GROQ, AI_OPENAI, save_full_config, get_default_anki_media_collection_path
16
22
  from GameSentenceMiner.util.db import AIModelsTable
17
23
  from GameSentenceMiner.util.downloader.download_tools import download_ocenaudio_if_needed
18
24
 
@@ -1,5 +1,7 @@
1
1
  import asyncio
2
+ import json
2
3
  import re
4
+ from datetime import datetime
3
5
 
4
6
  import pyperclip
5
7
  import requests
@@ -7,12 +9,11 @@ import websockets
7
9
  from websockets import InvalidStatus
8
10
  from rapidfuzz import fuzz
9
11
 
10
-
12
+ from GameSentenceMiner.util.configuration import get_config, gsm_status, logger, gsm_state
11
13
  from GameSentenceMiner.util.db import GameLinesTable
12
14
  from GameSentenceMiner.util.gsm_utils import do_text_replacements, TEXT_REPLACEMENTS_FILE, run_new_thread
13
- from GameSentenceMiner.util.configuration import *
14
- from GameSentenceMiner.util.text_log import *
15
15
  from GameSentenceMiner import obs
16
+ from GameSentenceMiner.util.text_log import add_line, get_text_log
16
17
  from GameSentenceMiner.web.texthooking_page import add_event_to_texthooker, overlay_server_thread
17
18
 
18
19
  from GameSentenceMiner.util.get_overlay_coords import OverlayProcessor
@@ -1,10 +1,11 @@
1
- import tempfile
2
- import time
3
1
  import asyncio
2
+ import os
3
+ import shutil
4
4
  import subprocess
5
5
  import sys
6
-
7
- import os
6
+ import tempfile
7
+ import threading
8
+ import time
8
9
  import warnings
9
10
 
10
11
  import requests
@@ -42,7 +43,10 @@ try:
42
43
  import psutil
43
44
 
44
45
  start_time = time.time()
45
- from GameSentenceMiner.util.configuration import *
46
+ from GameSentenceMiner.util.configuration import logger, gsm_state, get_config, anki_results, AnkiUpdateResult, \
47
+ get_temporary_directory, get_log_path, get_master_config, switch_profile_and_save, get_app_directory, gsm_status, \
48
+ is_windows, is_linux
49
+
46
50
  logger.debug(f"[Import] configuration: {time.time() - start_time:.3f}s")
47
51
 
48
52
  start_time = time.time()
@@ -113,10 +117,6 @@ try:
113
117
  logger.debug(
114
118
  f"[Import] util.text_log (GameLine, get_text_event, get_mined_line, get_all_lines, game_log): {time.time() - start_time:.3f}s")
115
119
 
116
- start_time = time.time()
117
- from GameSentenceMiner.util import *
118
- logger.debug(f"[Import] util *: {time.time() - start_time:.3f}s")
119
-
120
120
  start_time = time.time()
121
121
  from GameSentenceMiner.web import texthooking_page
122
122
  logger.debug(
@@ -675,6 +675,7 @@ def initialize_async():
675
675
 
676
676
 
677
677
  def handle_websocket_message(message: Message):
678
+ logger.info(f"WebSocket Message Received: {message.to_json()}")
678
679
  try:
679
680
  match FunctionName(message.function):
680
681
  case FunctionName.QUIT:
@@ -683,7 +684,7 @@ def handle_websocket_message(message: Message):
683
684
  case FunctionName.QUIT_OBS:
684
685
  close_obs()
685
686
  case FunctionName.START_OBS:
686
- obs.start_obs()
687
+ obs.start_obs(force_restart=not gsm_status.obs_connected)
687
688
  case FunctionName.OPEN_SETTINGS:
688
689
  open_settings()
689
690
  case FunctionName.OPEN_TEXTHOOKER:
@@ -165,28 +165,36 @@ class OBSConnectionManager(threading.Thread):
165
165
  self.counter = 0
166
166
  return
167
167
  start_replay_buffer()
168
-
168
+
169
169
  def get_obs_path():
170
170
  return os.path.join(configuration.get_app_directory(), 'obs-studio/bin/64bit/obs64.exe')
171
171
 
172
172
  def is_process_running(pid):
173
173
  try:
174
174
  process = psutil.Process(pid)
175
- return 'obs' in process.exe()
175
+ return 'obs' in process.exe().lower()
176
176
  except (psutil.NoSuchProcess, psutil.AccessDenied, OSError):
177
177
  if os.path.exists(OBS_PID_FILE):
178
178
  os.remove(OBS_PID_FILE)
179
179
  return False
180
180
 
181
- def start_obs():
181
+ def start_obs(force_restart=False):
182
182
  global obs_process_pid
183
183
  if os.path.exists(OBS_PID_FILE):
184
184
  with open(OBS_PID_FILE, "r") as f:
185
185
  try:
186
186
  obs_process_pid = int(f.read().strip())
187
187
  if is_process_running(obs_process_pid):
188
- print(f"OBS is already running with PID: {obs_process_pid}")
189
- return obs_process_pid
188
+ if force_restart:
189
+ try:
190
+ process = psutil.Process(obs_process_pid)
191
+ process.terminate()
192
+ process.wait(timeout=10)
193
+ print("OBS process terminated for restart.")
194
+ except Exception as e:
195
+ print(f"Error terminating OBS process: {e}")
196
+ else:
197
+ return obs_process_pid
190
198
  except ValueError:
191
199
  print("Invalid PID found in file. Launching new OBS instance.")
192
200
  except OSError:
@@ -19,13 +19,15 @@ from PIL import Image
19
19
  from rapidfuzz import fuzz
20
20
 
21
21
  from GameSentenceMiner import obs
22
- from GameSentenceMiner.util.electron_config import *
23
22
  from GameSentenceMiner.ocr.ss_picker import ScreenCropper
24
23
  from GameSentenceMiner.owocr.owocr.run import TextFiltering
25
24
  from GameSentenceMiner.util.configuration import get_config, get_app_directory, get_temporary_directory
26
25
  from GameSentenceMiner.ocr.gsm_ocr_config import OCRConfig, has_config_changed, set_dpi_awareness, get_window, get_ocr_config_path
27
- from GameSentenceMiner.owocr.owocr import screen_coordinate_picker, run
28
- from GameSentenceMiner.util.gsm_utils import sanitize_filename, do_text_replacements, OCR_REPLACEMENTS_FILE
26
+ from GameSentenceMiner.owocr.owocr import run
27
+ from GameSentenceMiner.util.electron_config import get_ocr_ocr2, get_ocr_send_to_clipboard, get_ocr_scan_rate, \
28
+ has_ocr_config_changed, reload_electron_config, get_ocr_two_pass_ocr, get_ocr_optimize_second_scan, \
29
+ get_ocr_language, get_ocr_manual_ocr_hotkey
30
+ from GameSentenceMiner.util.gsm_utils import sanitize_filename
29
31
  import threading
30
32
  import time
31
33
 
@@ -420,7 +422,7 @@ def get_ocr2_image(crop_coords, og_image: Image.Image, ocr2_engine=None):
420
422
  Logic is unchanged, but code is refactored for clarity and maintainability.
421
423
  """
422
424
  def return_original_image():
423
- logger.info("Returning original image for OCR2 (no cropping or optimization).")
425
+ logger.debug("Returning original image for OCR2 (no cropping or optimization).")
424
426
  if not crop_coords or not get_ocr_optimize_second_scan():
425
427
  return og_image
426
428
  x1, y1, x2, y2 = crop_coords
@@ -546,9 +548,10 @@ def add_ss_hotkey(ss_hotkey="ctrl+shift+g"):
546
548
  ocr_config = get_ocr_config()
547
549
  img = obs.get_screenshot_PIL(compression=80, img_format="jpg")
548
550
  ocr_config.scale_to_custom_size(img.width, img.height)
549
- img = run.apply_ocr_config_to_image(img, ocr_config, is_secondary=True)
550
- do_second_ocr("", datetime.now(), img, TextFiltering(lang=get_ocr_language()), ignore_furigana_filter=True, ignore_previous_result=True)
551
-
551
+ for rectangle in [rectangle for rectangle in ocr_config.rectangles if rectangle.is_secondary]:
552
+ new_img = run.apply_ocr_config_to_image(img, ocr_config, is_secondary=True, rectangles=[rectangle])
553
+ do_second_ocr("", datetime.now(), new_img, TextFiltering(lang=get_ocr_language()), ignore_furigana_filter=True, ignore_previous_result=True)
554
+
552
555
  filtering = TextFiltering(lang=get_ocr_language())
553
556
  cropper = ScreenCropper()
554
557
  def capture():
@@ -1,6 +1,11 @@
1
+ import os
2
+ import sys
3
+
1
4
  from GameSentenceMiner.ocr.gsm_ocr_config import set_dpi_awareness, get_scene_ocr_config
2
- from GameSentenceMiner.util.electron_config import * # noqa: F403
3
5
  from GameSentenceMiner.util.gsm_utils import do_text_replacements, OCR_REPLACEMENTS_FILE
6
+ from GameSentenceMiner.util.electron_config import get_ocr_language, get_ocr_requires_open_window, \
7
+ has_ocr_config_changed, reload_electron_config, get_ocr_scan_rate, get_ocr_two_pass_ocr, get_ocr_keep_newline, \
8
+ get_ocr_ocr1, get_furigana_filter_sensitivity
4
9
 
5
10
  try:
6
11
  import win32gui
@@ -1135,14 +1140,15 @@ def scale_down_width_height(width, height):
1135
1140
  return width, height
1136
1141
 
1137
1142
 
1138
- def apply_ocr_config_to_image(img, ocr_config, is_secondary=False):
1143
+ def apply_ocr_config_to_image(img, ocr_config, is_secondary=False, rectangles=None):
1139
1144
  for rectangle in ocr_config.rectangles:
1140
1145
  if rectangle.is_excluded:
1141
1146
  left, top, width, height = rectangle.coordinates
1142
1147
  draw = ImageDraw.Draw(img)
1143
1148
  draw.rectangle((left, top, left + width, top + height), fill=(0, 0, 0, 0))
1144
1149
 
1145
- rectangles = [r for r in ocr_config.rectangles if not r.is_excluded and r.is_secondary == is_secondary]
1150
+ if not rectangles:
1151
+ rectangles = [r for r in ocr_config.rectangles if not r.is_excluded and r.is_secondary == is_secondary]
1146
1152
 
1147
1153
  # Sort top to bottom
1148
1154
  if rectangles:
@@ -1,13 +1,16 @@
1
+ import json
2
+ import os
1
3
  import subprocess
4
+ import sys
2
5
  import tempfile
3
6
  import time
4
7
  from pathlib import Path
5
8
 
6
9
  from GameSentenceMiner import obs
10
+ from GameSentenceMiner.util.configuration import get_app_directory, is_windows, logger, get_config, \
11
+ get_temporary_directory, gsm_state, is_linux
7
12
  from GameSentenceMiner.util.gsm_utils import make_unique_file_name, get_file_modification_time
8
13
  from GameSentenceMiner.util import configuration
9
- from GameSentenceMiner.util.configuration import *
10
- from GameSentenceMiner.util.model import VADResult
11
14
  from GameSentenceMiner.util.text_log import initial_time
12
15
 
13
16
 
@@ -1,11 +1,14 @@
1
+ import json
2
+ import logging
3
+ import os
4
+ import shutil
1
5
  import tempfile
2
6
  import time
3
7
  import warnings
4
- import requests
5
8
  from abc import abstractmethod, ABC
6
9
 
7
10
  from GameSentenceMiner.util import configuration, ffmpeg
8
- from GameSentenceMiner.util.configuration import *
11
+ from GameSentenceMiner.util.configuration import get_config, get_temporary_directory, logger, SILERO, WHISPER
9
12
  from GameSentenceMiner.util.ffmpeg import get_audio_length
10
13
  from GameSentenceMiner.util.gsm_utils import make_unique_file_name, run_new_thread
11
14
  from GameSentenceMiner.util.model import VADResult
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: GameSentenceMiner
3
- Version: 2.17.0
3
+ Version: 2.17.1
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,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: GameSentenceMiner
3
- Version: 2.17.0
3
+ Version: 2.17.1
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
@@ -7,7 +7,7 @@ build-backend = "setuptools.build_meta"
7
7
 
8
8
  [project]
9
9
  name = "GameSentenceMiner"
10
- version = "2.17.0"
10
+ version = "2.17.1"
11
11
  description = "A tool for mining sentences from games. Update: Overlay?"
12
12
  readme = "README.md"
13
13
  requires-python = ">=3.10"
@@ -61,8 +61,8 @@ dependencies = [
61
61
  ]
62
62
 
63
63
  # This creates a command-line script named `gamesentenceminer` that will
64
- # call the `main()` function defined in the packages __main__.py (or wherever
65
- # youve placed your entry function). Adjust the import path as needed.
64
+ # call the `main()` function defined in the package's __main__.py (or wherever
65
+ # you've placed your entry function). Adjust the import path as needed.
66
66
  [project.scripts]
67
67
  gamesentenceminer = "GameSentenceMiner.gsm:main"
68
68