GameSentenceMiner 2.0.0.dev1__py3-none-any.whl → 2.0.1.post1__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.
@@ -5,6 +5,7 @@ import shutil
5
5
  from dataclasses import dataclass, field
6
6
  from logging.handlers import RotatingFileHandler
7
7
  from os.path import expanduser
8
+ from platform import platform
8
9
  from typing import List, Dict
9
10
 
10
11
  import toml
@@ -247,12 +248,17 @@ class Config:
247
248
  def get_all_profile_names(self):
248
249
  return list(self.configs.keys())
249
250
 
251
+
250
252
  def get_app_directory():
251
- appdata_dir = os.getenv('APPDATA') # Get the AppData directory
253
+ if platform == 'win32': # Windows
254
+ appdata_dir = os.getenv('APPDATA')
255
+ else: # macOS and Linux
256
+ appdata_dir = os.path.expanduser('~/.config')
252
257
  config_dir = os.path.join(appdata_dir, 'GameSentenceMiner')
253
258
  os.makedirs(config_dir, exist_ok=True) # Create the directory if it doesn't exist
254
259
  return config_dir
255
260
 
261
+
256
262
  def get_log_path():
257
263
  return os.path.join(get_app_directory(), 'gamesentenceminer.log')
258
264
 
GameSentenceMiner/obs.py CHANGED
@@ -1,8 +1,7 @@
1
1
  import time
2
+ from sys import platform
2
3
 
3
- import obswebsocket
4
4
  from obswebsocket import obsws, requests
5
- from obswebsocket.exceptions import ConnectionFailure
6
5
 
7
6
  from . import util
8
7
  from . import configuration
@@ -14,6 +13,47 @@ client: obsws = None
14
13
  # REFERENCE: https://github.com/obsproject/obs-websocket/blob/master/docs/generated/protocol.md
15
14
 
16
15
 
16
+ def get_obs_websocket_config_values():
17
+ if platform == "win32":
18
+ config_path = os.path.expanduser(r"~\AppData\Roaming\obs-studio\plugin_config\obs-websocket\config.json")
19
+ elif platform == "darwin": # macOS
20
+ config_path = os.path.expanduser(
21
+ "~/Library/Application Support/obs-studio/plugin_config/obs-websocket/config.json")
22
+ elif platform == "linux":
23
+ config_path = os.path.expanduser("~/.config/obs-studio/plugin_config/obs-websocket/config.json")
24
+ else:
25
+ raise Exception("Unsupported operating system.")
26
+
27
+ # Check if config file exists
28
+ if not os.path.isfile(config_path):
29
+ raise FileNotFoundError(f"OBS WebSocket config not found at {config_path}")
30
+
31
+ # Read the JSON configuration
32
+ with open(config_path, 'r') as file:
33
+ config = json.load(file)
34
+
35
+ # Extract values
36
+ server_enabled = config.get("server_enabled", False)
37
+ server_port = config.get("server_port", 4455) # Default to 4455 if not set
38
+ server_password = config.get("server_password", None)
39
+
40
+ if not server_enabled:
41
+ logger.info("OBS WebSocket server is not enabled. Enabling it now... Restart OBS for changes to take effect.")
42
+ config["server_enabled"] = True
43
+
44
+ with open(config_path, 'w') as file:
45
+ json.dump(config, file, indent=4)
46
+
47
+ if get_config().obs.password == 'your_password':
48
+ logger.info("OBS WebSocket password is not set. Setting it now...")
49
+ config = get_master_config()
50
+ config.get_config().obs.port = server_port
51
+ config.get_config().obs.password = server_password
52
+ with open(get_config_path(), 'w') as file:
53
+ json.dump(config.to_dict(), file, indent=4)
54
+ reload_config()
55
+
56
+
17
57
  def on_connect(obs):
18
58
  logger.info("Connected to OBS WebSocket.")
19
59
  time.sleep(2)
@@ -28,14 +68,11 @@ def on_disconnect(obs):
28
68
  def connect_to_obs(start_replay=False):
29
69
  global client
30
70
  if get_config().obs.enabled:
71
+ get_obs_websocket_config_values()
31
72
  client = obsws(host=get_config().obs.host, port=get_config().obs.port,
32
73
  password=get_config().obs.password, authreconnect=1, on_connect=on_connect,
33
74
  on_disconnect=on_disconnect)
34
- try:
35
- client.connect()
36
- except ConnectionFailure:
37
- logger.error("OBS Websocket Connection Has not been Set up, please set it up in Settings")
38
- exit(1)
75
+ client.connect()
39
76
 
40
77
  time.sleep(1)
41
78
  if start_replay and get_config().obs.start_buffer:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: GameSentenceMiner
3
- Version: 2.0.0.dev1
3
+ Version: 2.0.1.post1
4
4
  Summary: A tool for mining sentences from games.
5
5
  Author-email: Beangate <bpwhelan95@gmail.com>
6
6
  License: MIT License
@@ -38,6 +38,12 @@ Requires-Dist: pywin32
38
38
 
39
39
  # Sentence Mining Game Audio Trim Helper
40
40
 
41
+ ## WARNING
42
+
43
+ This project is in process of a major rewrite, and this README will be updated soon with the new process.
44
+
45
+ ---
46
+
41
47
  This project automates the recording of game sentence audio to help with Anki Card Creation.
42
48
 
43
49
  This allows us to create cards from texthooker/yomitan, and automatically get screenshot and sentence audio from the
@@ -280,7 +286,7 @@ Screenshots to help with setup:
280
286
 
281
287
  1. Start game
282
288
  2. Hook Game with Agent (or textractor) with clipboard enabled
283
- 3. start script: `python main.py`
289
+ 3. start script: `python -m src.GameSentenceMiner.gsm`
284
290
  1. Create Anki Card with target word (through a texthooker page/Yomitan)
285
291
  2. (If full-auto-mode not on) Trigger Hotkey to record replay buffer
286
292
  4. When finished gaming, end script
@@ -1,20 +1,20 @@
1
1
  GameSentenceMiner/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
2
  GameSentenceMiner/anki.py,sha256=3UT6K5PxzJMDoiXyOULrkeCoJ0KMq7JvBw6XhcLCirE,9114
3
3
  GameSentenceMiner/config_gui.py,sha256=s03e8F2pEPj0iG31RxFqWGfm2GLb8JoGQR7QhCMFu3M,45581
4
- GameSentenceMiner/configuration.py,sha256=7sXYNBNXyezPFbGKTu2XwjMAy6vQ1tJPfLg2aq2UGRA,13859
4
+ GameSentenceMiner/configuration.py,sha256=6DtBPbAqvAEFrRZFxIdnzb1kaJLLd5D29XJJyrLjgno,13988
5
5
  GameSentenceMiner/ffmpeg.py,sha256=hdKimzkpAKsE-17qEAQg4uHy4-TtdFywYx48Skn9cPs,10418
6
6
  GameSentenceMiner/gametext.py,sha256=GpR9P8h3GmmKH46Dw13kJPx66n3jGjFCiV8Fcrqn9E8,3999
7
7
  GameSentenceMiner/gsm.py,sha256=Lnj59KHV4l5eEgffkswBlRCONgYB_Id3L0pTajUzsvI,14937
8
8
  GameSentenceMiner/model.py,sha256=oh8VVT8T1UKekbmP6MGNgQ8jIuQ_7Rg4GPzDCn2kJo8,1999
9
9
  GameSentenceMiner/notification.py,sha256=sWgIIXhaB9WV1K_oQGf5-IR6q3dakae_QS-RuIvbcEs,1939
10
- GameSentenceMiner/obs.py,sha256=VH9qXRbmxWxFgcp6iGzEQUseyxf_qINCOM54ByGa7_0,3698
10
+ GameSentenceMiner/obs.py,sha256=gutnRk30jIxuvrpEosR9jw2h_tll36wgtAZkUF-vWDY,5256
11
11
  GameSentenceMiner/util.py,sha256=OYg0j_rT9F7v3aJRwWnHvdWMYyxGlimrvw7U2C9ifeY,4441
12
12
  GameSentenceMiner/vad/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
13
13
  GameSentenceMiner/vad/silero_trim.py,sha256=r7bZYEj-NUXGKgD2UIhLrbTPyq0rau97qGtrMZcRK4A,1517
14
14
  GameSentenceMiner/vad/vosk_helper.py,sha256=lWmlGMhmg_0QoWeCHrXwz9wDKPqY37BckHCekGVtJUI,5794
15
15
  GameSentenceMiner/vad/whisper_helper.py,sha256=9kmPeSs6jRcKSVxYY-vtyTcqVUDORR4q1nl8fqxHHn4,3379
16
- GameSentenceMiner-2.0.0.dev1.dist-info/METADATA,sha256=32ajZFt816JeijN0hktOxA656mnWWT_5rSnSUK16PjI,13394
17
- GameSentenceMiner-2.0.0.dev1.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
18
- GameSentenceMiner-2.0.0.dev1.dist-info/entry_points.txt,sha256=2APEP25DbfjSxGeHtwBstMH8mulVhLkqF_b9bqzU6vQ,65
19
- GameSentenceMiner-2.0.0.dev1.dist-info/top_level.txt,sha256=V1hUY6xVSyUEohb0uDoN4UIE6rUZ_JYx8yMyPGX4PgQ,18
20
- GameSentenceMiner-2.0.0.dev1.dist-info/RECORD,,
16
+ GameSentenceMiner-2.0.1.post1.dist-info/METADATA,sha256=_xBUL_ZCFHf9JNbWA3G62p5slogTGPCQoJr60ebMZj4,13540
17
+ GameSentenceMiner-2.0.1.post1.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
18
+ GameSentenceMiner-2.0.1.post1.dist-info/entry_points.txt,sha256=2APEP25DbfjSxGeHtwBstMH8mulVhLkqF_b9bqzU6vQ,65
19
+ GameSentenceMiner-2.0.1.post1.dist-info/top_level.txt,sha256=V1hUY6xVSyUEohb0uDoN4UIE6rUZ_JYx8yMyPGX4PgQ,18
20
+ GameSentenceMiner-2.0.1.post1.dist-info/RECORD,,