GameSentenceMiner 2.0.0__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 (25) hide show
  1. gamesentenceminer-2.0.0/PKG-INFO +346 -0
  2. gamesentenceminer-2.0.0/README.md +308 -0
  3. gamesentenceminer-2.0.0/pyproject.toml +59 -0
  4. gamesentenceminer-2.0.0/setup.cfg +4 -0
  5. gamesentenceminer-2.0.0/src/GameSentenceMiner/__init__.py +0 -0
  6. gamesentenceminer-2.0.0/src/GameSentenceMiner/anki.py +265 -0
  7. gamesentenceminer-2.0.0/src/GameSentenceMiner/config_gui.py +803 -0
  8. gamesentenceminer-2.0.0/src/GameSentenceMiner/configuration.py +359 -0
  9. gamesentenceminer-2.0.0/src/GameSentenceMiner/ffmpeg.py +297 -0
  10. gamesentenceminer-2.0.0/src/GameSentenceMiner/gametext.py +128 -0
  11. gamesentenceminer-2.0.0/src/GameSentenceMiner/gsm.py +385 -0
  12. gamesentenceminer-2.0.0/src/GameSentenceMiner/model.py +84 -0
  13. gamesentenceminer-2.0.0/src/GameSentenceMiner/notification.py +69 -0
  14. gamesentenceminer-2.0.0/src/GameSentenceMiner/obs.py +128 -0
  15. gamesentenceminer-2.0.0/src/GameSentenceMiner/util.py +136 -0
  16. gamesentenceminer-2.0.0/src/GameSentenceMiner/vad/__init__.py +0 -0
  17. gamesentenceminer-2.0.0/src/GameSentenceMiner/vad/silero_trim.py +43 -0
  18. gamesentenceminer-2.0.0/src/GameSentenceMiner/vad/vosk_helper.py +152 -0
  19. gamesentenceminer-2.0.0/src/GameSentenceMiner/vad/whisper_helper.py +98 -0
  20. gamesentenceminer-2.0.0/src/GameSentenceMiner.egg-info/PKG-INFO +346 -0
  21. gamesentenceminer-2.0.0/src/GameSentenceMiner.egg-info/SOURCES.txt +23 -0
  22. gamesentenceminer-2.0.0/src/GameSentenceMiner.egg-info/dependency_links.txt +1 -0
  23. gamesentenceminer-2.0.0/src/GameSentenceMiner.egg-info/entry_points.txt +2 -0
  24. gamesentenceminer-2.0.0/src/GameSentenceMiner.egg-info/requires.txt +24 -0
  25. gamesentenceminer-2.0.0/src/GameSentenceMiner.egg-info/top_level.txt +1 -0
@@ -0,0 +1,346 @@
1
+ Metadata-Version: 2.2
2
+ Name: GameSentenceMiner
3
+ Version: 2.0.0
4
+ Summary: A tool for mining sentences from games.
5
+ Author-email: Beangate <bpwhelan95@gmail.com>
6
+ License: MIT License
7
+ Project-URL: Homepage, https://github.com/bpwhelan/GameSentenceMiner
8
+ Project-URL: Repository, https://github.com/bpwhelan/GameSentenceMiner
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Operating System :: OS Independent
12
+ Requires-Python: >=3.11
13
+ Description-Content-Type: text/markdown
14
+ Requires-Dist: requests~=2.32.3
15
+ Requires-Dist: anki~=24.6.3
16
+ Requires-Dist: watchdog~=5.0.2
17
+ Requires-Dist: DateTime~=5.5
18
+ Requires-Dist: pyperclip~=1.9.0
19
+ Requires-Dist: vosk~=0.3.45
20
+ Requires-Dist: soundfile~=0.12.1
21
+ Requires-Dist: toml~=0.10.2
22
+ Requires-Dist: psutil~=6.0.0
23
+ Requires-Dist: rapidfuzz~=3.9.7
24
+ Requires-Dist: obs-websocket-py~=1.0
25
+ Requires-Dist: plyer~=2.1.0
26
+ Requires-Dist: keyboard~=0.13.5
27
+ Requires-Dist: websockets~=13.0.1
28
+ Requires-Dist: obsws_python~=1.7.0
29
+ Requires-Dist: numpy~=2.0.2
30
+ Requires-Dist: stable-ts~=2.17.5
31
+ Requires-Dist: openai-whisper
32
+ Requires-Dist: silero-vad~=5.1.2
33
+ Requires-Dist: ttkbootstrap~=1.10.1
34
+ Requires-Dist: dataclasses_json~=0.6.7
35
+ Requires-Dist: pyinstaller
36
+ Requires-Dist: pystray
37
+ Requires-Dist: pywin32
38
+
39
+ # Sentence Mining Game Audio Trim Helper
40
+
41
+ This project automates the recording of game sentence audio to help with Anki Card Creation.
42
+
43
+ This allows us to create cards from texthooker/yomitan, and automatically get screenshot and sentence audio from the
44
+ game we are playing.
45
+
46
+ ## Features:
47
+
48
+ - **Voice Activity Detection**: Automatically cuts the end of the clip to the exact moment the voice ended.
49
+ - **OBS Replay Buffer**: Constantly records the last X seconds of gameplay.
50
+ - **Clipboard Interaction**: Automatically monitors the clipboard for dialogue events.
51
+ - **Websocket Listening**: Listens to a websocket uri for text-events from stuff like Agent/Textractor.
52
+ - **Hotkey Automation**: Single hotkey to trigger video recording, screenshot, and transcription.
53
+ - **1-Click Card Creation**: Monitors anki for new cards from Yomitan, and automatically gets audio from games.
54
+
55
+ ## Prerequisites
56
+
57
+ - [Python 3.11+](https://www.python.org/downloads/)
58
+ - [OBS Studio](https://obsproject.com/)
59
+
60
+ ---
61
+
62
+ ### Quick Disclaimer/Troubleshooting
63
+
64
+ Every game/hook is different, so it's really impossible that any script can get it perfect everytime. Also OBS is
65
+ sometimes a bit finnicky if running for too long. If the audio timing is off, please first try some troubleshooting
66
+ steps before making an issue:
67
+
68
+ - Try Restarting OBS
69
+ - Make sure your hook is the best you can find. (Preferrably it gives you the text RIGHT when the voiceline starts)
70
+ - Try Adjusting Offset Configuration in `config.toml` to better match your situation. (i.e. if the hook is late, add a
71
+ negative beginning offset)
72
+ - Try using "Trim beginning" in `VAD` settings.
73
+
74
+ #### Setup Troubleshooting
75
+
76
+ Just going to continuously update this with issues that I have helped users with. Look here first if you have issues
77
+ setting it up.
78
+
79
+ - Make sure folder_to_watch is the same as your recordings path in OBS. It defaults to ~/Videos, but I recommend setting
80
+ it to ~/Videos/OBS.
81
+ - if it says something about a missing library, attempt to run `pip install -r requirements.txt` again
82
+ - If using clipboard, make sure agent/textractor sending to clipboard is enabled.
83
+
84
+ ## 1. Setting Up OBS 60-Second Replay Buffer
85
+
86
+ 1. **Install OBS Studio**: Download and install OBS from [here](https://obsproject.com/).
87
+ 2. **Enable Replay Buffer**:
88
+ 1. Open OBS and navigate to **Settings → Output → Replay Buffer**.
89
+ 2. Enable the **Replay Buffer** and set the duration to **60 seconds**, this can be lower, or higher, but 60 works
90
+ for a very simple setup.
91
+ 3. **Set a Hotkey for the Replay Buffer**:
92
+ 1. Go to **Settings → Hotkeys** and find **Save Replay Buffer**.
93
+ 2. Assign a hotkey for saving the replay.
94
+ 4. Set Scene/Source. I recommend using "Game Capture" with "Capture Audio" Enabled. And then mute Desktop/microphone
95
+ 1. If "Game Capture" Does not work, use "Window Capture".
96
+ 2. I recommend having a Scene PER Game, with the name of the scene labeled as the game, this makes it easier for the
97
+ script to know (with a config option) what game you are playing.
98
+ 5. In Output Settings, set "Recording Format" to mkv, and "Audio Encoder" to Opus. Alternative Settings may be supported
99
+ at a later date.
100
+ 6. **Set up obs websocket** (HIGHLY RECOMMENDED see #5)
101
+ 1. Can allow my script to automatically start (and stop) the replay buffer, as well as automatically add
102
+ audio/screenshot to card created from yomi.
103
+
104
+ Here are the Settings I use in OBS. Make sure the recordings folder is the same as the "folder_to_watch" in the config.
105
+ ![image](https://github.com/user-attachments/assets/0056816d-af3c-4a3c-bc6a-4aff5c28cadb)
106
+ ![image](https://github.com/user-attachments/assets/dd2f95a6-f546-41d9-8136-de7b1b035a5d)
107
+
108
+
109
+ ---
110
+
111
+ ## 2. Configuring the App.
112
+
113
+ ### Configuration GUI
114
+
115
+ The `GameSentenceMiner` project now includes a graphical interface to simplify configuration. With default values
116
+ already set, this GUI lets you adjust settings as needed. Here’s how to get started:
117
+
118
+ #### Running the Configuration GUI
119
+
120
+ To open the GUI, you have two options:
121
+
122
+ 1. **Tray Icon**: Right Click the Tray Icon and Click `Open Settings`
123
+ 2. **Directly Run the Script**: Open a terminal in your project directory and enter:
124
+ \\\bash
125
+ python config_gui.py
126
+ \\\
127
+
128
+ #### Default Settings and Customization
129
+
130
+ The GUI loads with default values for each setting, so if you’re just getting started, you may only need to change stuff
131
+ in the "path" config. If you make changes, remember to click **Save Settings** to apply them.
132
+ Please take a second to look through the config to see what is available, there is a lot of extra functionality hidden
133
+ behind config options.
134
+
135
+ ![image](https://github.com/user-attachments/assets/ffac9888-de0a-412b-817f-e22a55ce7b55)![image](https://github.com/user-attachments/assets/981c112a-1ddc-4e07-9c39-57fe46644ff5)![image](https://github.com/user-attachments/assets/29470a97-6013-4ca8-9059-48af735eb3a8)![image](https://github.com/user-attachments/assets/8e9c8f03-dc43-4822-a3c5-43f36ca65364)
136
+
137
+
138
+
139
+
140
+
141
+ ---
142
+
143
+ ## 2. Configuring `config.toml` **DEPRECATED** Only used if running an older version.
144
+
145
+ I redid the config parsing cause `config.py` is not ideal, especially when distributing a script via git.
146
+
147
+ Your `config.toml` file allows you to configure key settings for the automation process, file paths, and other behavior.
148
+ Here are the configurable options:
149
+
150
+ Duplicate/rename config_EXAMPLE.toml to get started
151
+
152
+ ```toml
153
+ # Path configurations
154
+ [paths]
155
+ folder_to_watch = "~/Videos/OBS"
156
+ audio_destination = "~/Videos/OBS/Audio/"
157
+ screenshot_destination = "~/Videos/OBS/SS/"
158
+
159
+ # Anki Fields
160
+ [anki]
161
+ url = 'http://127.0.0.1:8765'
162
+ sentence_field = "Sentence"
163
+ sentence_audio_field = "SentenceAudio"
164
+ picture_field = "Picture"
165
+ word_field = "Word"
166
+ current_game = "Japanese Game"
167
+ custom_tags = ['JapaneseGameMiner', "Test Another Tag"] # leave Empty if you dont want to add tags
168
+ add_game_tag = true
169
+ polling_rate = 200 # This is how often the script asks anki if it has new cards. Change at your own peril.
170
+
171
+ # Feature Flags
172
+ [features]
173
+ do_vosk_postprocessing = true
174
+ update_anki = true
175
+ remove_video = true
176
+ remove_screenshot = false
177
+ remove_audio = false
178
+ notify_on_update = true
179
+ open_anki_edit = false
180
+ backfill_audio = false # Strictly to fill audio for cards that you already have in your anki db. CANNOT BE USED WITH FULL_AUTO_MODE
181
+
182
+ # Vosk Model
183
+ [vosk]
184
+ url = "https://alphacephei.com/vosk/models/vosk-model-small-ja-0.22.zip"
185
+ # If you have a high-performance PC, with 16GB+ of RAM, you can uncomment and use this model:
186
+ # url = "https://alphacephei.com/vosk/models/vosk-model-ja-0.22.zip"
187
+ log-level = -1
188
+
189
+ [screenshot]
190
+ width = 0 # Desired Width of Screenshot, 0 to disable scaling (Default 0)
191
+ quality = 85 # Quality of image, 100 is lossless (Default 85)
192
+ extension = "webp" # Codec of screenshot, Recommend Keeping this as webp (Default webp)
193
+
194
+ [audio]
195
+ extension = "opus" # Desired Extension/codec of Trimmed Audio, (Default opus)
196
+ beginning_offset = 0.0 # Negative Value = More time at the beginning (i.e. -1 is 1 extra second at the beginning)
197
+ end_offset = 0.5 # Positive Value = More time at the end (i.e. 1 is 1 extra second at the end)
198
+ vosk_trim_beginning = false # Only change If you run into issues with clipboard timing, add a negative beginning_offset as well, Warning: You may end up with audio from previous line depending on your setup!
199
+ reset_hotkey = 'f4' # Hotkey to initiate Offset Updater.
200
+
201
+ [obs]
202
+ enabled = true
203
+ start_buffer = true
204
+ full_auto_mode = false # Automatically Create Cards when you Create in Yomi. REQUIRED for multi-card-per-voiceline
205
+ host = "localhost"
206
+ port = 4455
207
+ password = "your_password_here"
208
+ get_game_from_scene = false
209
+
210
+ [websocket]
211
+ enabled = true # Recommended/Default, with this enabled, this script does not interact with your clipboard at all.
212
+ uri = 'localhost:6677'
213
+
214
+ #[anki_custom_fields]
215
+ #IsTargetedSentenceCard = 1
216
+ #Comment = "Nice!"
217
+ ```
218
+
219
+ ---
220
+
221
+ ## 3. Install Requirements
222
+
223
+ If you know what you are doing, do this in a venv, but I'm not going to explain that here.
224
+
225
+ `pip install -r requirements.txt`
226
+
227
+ ## 4. Installing FFmpeg
228
+
229
+ To run this script, you will need to have **FFmpeg** installed. If you don't have FFmpeg installed on your system, you
230
+ can easily install it via **Chocolatey** (Preferred), or install it yourself and ensure it's in the PATH.
231
+
232
+ #### Step-by-Step Instructions:
233
+
234
+ 1. First, ensure you have **Chocolatey** installed. If you don't have it installed, follow the instructions on
235
+ the [Chocolatey installation page](https://chocolatey.org/install) or run the following command in an **elevated**
236
+ PowerShell window (run as Administrator):
237
+
238
+ ```bash
239
+ Set-ExecutionPolicy Bypass -Scope Process -Force; `
240
+ [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; `
241
+ iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
242
+ ```
243
+
244
+ 2. Once Chocolatey is installed, open a **new** PowerShell or Command Prompt window (with administrator rights).
245
+
246
+ 3. Run the following command to install FFmpeg:
247
+
248
+ ```bash
249
+ choco install ffmpeg
250
+ ```
251
+
252
+ 4. After the installation is complete, verify that FFmpeg is correctly installed by running the following command:
253
+
254
+ ```bash
255
+ ffmpeg -version
256
+ ```
257
+
258
+ If the installation was successful, you should see the version information for FFmpeg.
259
+
260
+ Now you're ready to use FFmpeg in the script!
261
+
262
+ ---
263
+
264
+ ## 5. One Click Card Creation
265
+
266
+ This is the flagship feature of this script, so here is a section explaining it. It is possible to do full 1-click card
267
+ creation with this tool + Yomitan. The relevant settings are located in `Features` and `OBS` section in the config.
268
+
269
+ Demo: https://www.youtube.com/watch?v=9dmmXO2CGNw
270
+
271
+ Screenshots to help with setup:
272
+
273
+ ![image](https://github.com/user-attachments/assets/7de031e9-ce28-42eb-a8fd-0e60ef70dc3d)
274
+
275
+ ![image](https://github.com/user-attachments/assets/b0c70a1a-65b5-4fe7-a7e4-ccb0b9a5b249)
276
+
277
+ ![image](https://github.com/user-attachments/assets/4cf492eb-12a2-429f-aa0e-f87fc0fa6270)
278
+
279
+ ## 6. Example Process
280
+
281
+ 1. Start game
282
+ 2. Hook Game with Agent (or textractor) with clipboard enabled
283
+ 3. start script: `python main.py`
284
+ 1. Create Anki Card with target word (through a texthooker page/Yomitan)
285
+ 2. (If full-auto-mode not on) Trigger Hotkey to record replay buffer
286
+ 4. When finished gaming, end script
287
+
288
+ Once the hotkey is triggered:
289
+
290
+ 1. **OBS** will save the last X seconds of gameplay.
291
+ 2. The Python script will trim the audio based on last clipboard event, and the end of voiceline detected in Vosk if
292
+ enabled.
293
+ 3. Will attempt to update the LAST anki card created.
294
+
295
+ ---
296
+
297
+ ## How to Update the Script
298
+
299
+ ### Updater (Preferred)
300
+
301
+ There is now an Update script included! running `python update.py` in the directory will attempt to update your scripts
302
+ to the latest release. If you have made changes to any of the files, they will be safely backed up before being
303
+ replaced.
304
+
305
+ ---
306
+
307
+ ### Manual
308
+
309
+ To ensure you always have the latest version of this script, you can use `git pull` to update your local repository with
310
+ the latest changes from the remote repository.
311
+
312
+ #### Step-by-Step Instructions
313
+
314
+ 1. Open your terminal and navigate to the directory where you cloned the repository:
315
+ ```bash
316
+ cd path/to/script
317
+ ```
318
+
319
+ 2. Run the following command to fetch and integrate the latest changes:
320
+ ```bash
321
+ git pull origin main
322
+ ```
323
+
324
+ - **`origin`** refers to the remote repository from which you cloned the code.
325
+ - **`main`** refers to the main branch of the repository. If your default branch has a different name (
326
+ e.g., `master` or `dev`), replace `main` with that branch name.
327
+
328
+ 3. The `git pull` command will download and apply any updates from the remote repository to your local version.
329
+
330
+ ### Example:
331
+
332
+ ```bash
333
+ $ cd path/to/script
334
+ $ git pull origin master
335
+ ```
336
+
337
+ ---
338
+
339
+ ## Contact
340
+
341
+ If you run into issues ask in my [discord](https://discord.gg/yP8Qse6bb8), or make an issue here.
342
+
343
+ ## Donations
344
+
345
+ If you've benefited from this or any of my other projects, please consider supporting my work
346
+ via [Github Sponsors](https://github.com/sponsors/bpwhelan) or [Ko-fi.](https://ko-fi.com/beangate)
@@ -0,0 +1,308 @@
1
+ # Sentence Mining Game Audio Trim Helper
2
+
3
+ This project automates the recording of game sentence audio to help with Anki Card Creation.
4
+
5
+ This allows us to create cards from texthooker/yomitan, and automatically get screenshot and sentence audio from the
6
+ game we are playing.
7
+
8
+ ## Features:
9
+
10
+ - **Voice Activity Detection**: Automatically cuts the end of the clip to the exact moment the voice ended.
11
+ - **OBS Replay Buffer**: Constantly records the last X seconds of gameplay.
12
+ - **Clipboard Interaction**: Automatically monitors the clipboard for dialogue events.
13
+ - **Websocket Listening**: Listens to a websocket uri for text-events from stuff like Agent/Textractor.
14
+ - **Hotkey Automation**: Single hotkey to trigger video recording, screenshot, and transcription.
15
+ - **1-Click Card Creation**: Monitors anki for new cards from Yomitan, and automatically gets audio from games.
16
+
17
+ ## Prerequisites
18
+
19
+ - [Python 3.11+](https://www.python.org/downloads/)
20
+ - [OBS Studio](https://obsproject.com/)
21
+
22
+ ---
23
+
24
+ ### Quick Disclaimer/Troubleshooting
25
+
26
+ Every game/hook is different, so it's really impossible that any script can get it perfect everytime. Also OBS is
27
+ sometimes a bit finnicky if running for too long. If the audio timing is off, please first try some troubleshooting
28
+ steps before making an issue:
29
+
30
+ - Try Restarting OBS
31
+ - Make sure your hook is the best you can find. (Preferrably it gives you the text RIGHT when the voiceline starts)
32
+ - Try Adjusting Offset Configuration in `config.toml` to better match your situation. (i.e. if the hook is late, add a
33
+ negative beginning offset)
34
+ - Try using "Trim beginning" in `VAD` settings.
35
+
36
+ #### Setup Troubleshooting
37
+
38
+ Just going to continuously update this with issues that I have helped users with. Look here first if you have issues
39
+ setting it up.
40
+
41
+ - Make sure folder_to_watch is the same as your recordings path in OBS. It defaults to ~/Videos, but I recommend setting
42
+ it to ~/Videos/OBS.
43
+ - if it says something about a missing library, attempt to run `pip install -r requirements.txt` again
44
+ - If using clipboard, make sure agent/textractor sending to clipboard is enabled.
45
+
46
+ ## 1. Setting Up OBS 60-Second Replay Buffer
47
+
48
+ 1. **Install OBS Studio**: Download and install OBS from [here](https://obsproject.com/).
49
+ 2. **Enable Replay Buffer**:
50
+ 1. Open OBS and navigate to **Settings → Output → Replay Buffer**.
51
+ 2. Enable the **Replay Buffer** and set the duration to **60 seconds**, this can be lower, or higher, but 60 works
52
+ for a very simple setup.
53
+ 3. **Set a Hotkey for the Replay Buffer**:
54
+ 1. Go to **Settings → Hotkeys** and find **Save Replay Buffer**.
55
+ 2. Assign a hotkey for saving the replay.
56
+ 4. Set Scene/Source. I recommend using "Game Capture" with "Capture Audio" Enabled. And then mute Desktop/microphone
57
+ 1. If "Game Capture" Does not work, use "Window Capture".
58
+ 2. I recommend having a Scene PER Game, with the name of the scene labeled as the game, this makes it easier for the
59
+ script to know (with a config option) what game you are playing.
60
+ 5. In Output Settings, set "Recording Format" to mkv, and "Audio Encoder" to Opus. Alternative Settings may be supported
61
+ at a later date.
62
+ 6. **Set up obs websocket** (HIGHLY RECOMMENDED see #5)
63
+ 1. Can allow my script to automatically start (and stop) the replay buffer, as well as automatically add
64
+ audio/screenshot to card created from yomi.
65
+
66
+ Here are the Settings I use in OBS. Make sure the recordings folder is the same as the "folder_to_watch" in the config.
67
+ ![image](https://github.com/user-attachments/assets/0056816d-af3c-4a3c-bc6a-4aff5c28cadb)
68
+ ![image](https://github.com/user-attachments/assets/dd2f95a6-f546-41d9-8136-de7b1b035a5d)
69
+
70
+
71
+ ---
72
+
73
+ ## 2. Configuring the App.
74
+
75
+ ### Configuration GUI
76
+
77
+ The `GameSentenceMiner` project now includes a graphical interface to simplify configuration. With default values
78
+ already set, this GUI lets you adjust settings as needed. Here’s how to get started:
79
+
80
+ #### Running the Configuration GUI
81
+
82
+ To open the GUI, you have two options:
83
+
84
+ 1. **Tray Icon**: Right Click the Tray Icon and Click `Open Settings`
85
+ 2. **Directly Run the Script**: Open a terminal in your project directory and enter:
86
+ \\\bash
87
+ python config_gui.py
88
+ \\\
89
+
90
+ #### Default Settings and Customization
91
+
92
+ The GUI loads with default values for each setting, so if you’re just getting started, you may only need to change stuff
93
+ in the "path" config. If you make changes, remember to click **Save Settings** to apply them.
94
+ Please take a second to look through the config to see what is available, there is a lot of extra functionality hidden
95
+ behind config options.
96
+
97
+ ![image](https://github.com/user-attachments/assets/ffac9888-de0a-412b-817f-e22a55ce7b55)![image](https://github.com/user-attachments/assets/981c112a-1ddc-4e07-9c39-57fe46644ff5)![image](https://github.com/user-attachments/assets/29470a97-6013-4ca8-9059-48af735eb3a8)![image](https://github.com/user-attachments/assets/8e9c8f03-dc43-4822-a3c5-43f36ca65364)
98
+
99
+
100
+
101
+
102
+
103
+ ---
104
+
105
+ ## 2. Configuring `config.toml` **DEPRECATED** Only used if running an older version.
106
+
107
+ I redid the config parsing cause `config.py` is not ideal, especially when distributing a script via git.
108
+
109
+ Your `config.toml` file allows you to configure key settings for the automation process, file paths, and other behavior.
110
+ Here are the configurable options:
111
+
112
+ Duplicate/rename config_EXAMPLE.toml to get started
113
+
114
+ ```toml
115
+ # Path configurations
116
+ [paths]
117
+ folder_to_watch = "~/Videos/OBS"
118
+ audio_destination = "~/Videos/OBS/Audio/"
119
+ screenshot_destination = "~/Videos/OBS/SS/"
120
+
121
+ # Anki Fields
122
+ [anki]
123
+ url = 'http://127.0.0.1:8765'
124
+ sentence_field = "Sentence"
125
+ sentence_audio_field = "SentenceAudio"
126
+ picture_field = "Picture"
127
+ word_field = "Word"
128
+ current_game = "Japanese Game"
129
+ custom_tags = ['JapaneseGameMiner', "Test Another Tag"] # leave Empty if you dont want to add tags
130
+ add_game_tag = true
131
+ polling_rate = 200 # This is how often the script asks anki if it has new cards. Change at your own peril.
132
+
133
+ # Feature Flags
134
+ [features]
135
+ do_vosk_postprocessing = true
136
+ update_anki = true
137
+ remove_video = true
138
+ remove_screenshot = false
139
+ remove_audio = false
140
+ notify_on_update = true
141
+ open_anki_edit = false
142
+ backfill_audio = false # Strictly to fill audio for cards that you already have in your anki db. CANNOT BE USED WITH FULL_AUTO_MODE
143
+
144
+ # Vosk Model
145
+ [vosk]
146
+ url = "https://alphacephei.com/vosk/models/vosk-model-small-ja-0.22.zip"
147
+ # If you have a high-performance PC, with 16GB+ of RAM, you can uncomment and use this model:
148
+ # url = "https://alphacephei.com/vosk/models/vosk-model-ja-0.22.zip"
149
+ log-level = -1
150
+
151
+ [screenshot]
152
+ width = 0 # Desired Width of Screenshot, 0 to disable scaling (Default 0)
153
+ quality = 85 # Quality of image, 100 is lossless (Default 85)
154
+ extension = "webp" # Codec of screenshot, Recommend Keeping this as webp (Default webp)
155
+
156
+ [audio]
157
+ extension = "opus" # Desired Extension/codec of Trimmed Audio, (Default opus)
158
+ beginning_offset = 0.0 # Negative Value = More time at the beginning (i.e. -1 is 1 extra second at the beginning)
159
+ end_offset = 0.5 # Positive Value = More time at the end (i.e. 1 is 1 extra second at the end)
160
+ vosk_trim_beginning = false # Only change If you run into issues with clipboard timing, add a negative beginning_offset as well, Warning: You may end up with audio from previous line depending on your setup!
161
+ reset_hotkey = 'f4' # Hotkey to initiate Offset Updater.
162
+
163
+ [obs]
164
+ enabled = true
165
+ start_buffer = true
166
+ full_auto_mode = false # Automatically Create Cards when you Create in Yomi. REQUIRED for multi-card-per-voiceline
167
+ host = "localhost"
168
+ port = 4455
169
+ password = "your_password_here"
170
+ get_game_from_scene = false
171
+
172
+ [websocket]
173
+ enabled = true # Recommended/Default, with this enabled, this script does not interact with your clipboard at all.
174
+ uri = 'localhost:6677'
175
+
176
+ #[anki_custom_fields]
177
+ #IsTargetedSentenceCard = 1
178
+ #Comment = "Nice!"
179
+ ```
180
+
181
+ ---
182
+
183
+ ## 3. Install Requirements
184
+
185
+ If you know what you are doing, do this in a venv, but I'm not going to explain that here.
186
+
187
+ `pip install -r requirements.txt`
188
+
189
+ ## 4. Installing FFmpeg
190
+
191
+ To run this script, you will need to have **FFmpeg** installed. If you don't have FFmpeg installed on your system, you
192
+ can easily install it via **Chocolatey** (Preferred), or install it yourself and ensure it's in the PATH.
193
+
194
+ #### Step-by-Step Instructions:
195
+
196
+ 1. First, ensure you have **Chocolatey** installed. If you don't have it installed, follow the instructions on
197
+ the [Chocolatey installation page](https://chocolatey.org/install) or run the following command in an **elevated**
198
+ PowerShell window (run as Administrator):
199
+
200
+ ```bash
201
+ Set-ExecutionPolicy Bypass -Scope Process -Force; `
202
+ [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; `
203
+ iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
204
+ ```
205
+
206
+ 2. Once Chocolatey is installed, open a **new** PowerShell or Command Prompt window (with administrator rights).
207
+
208
+ 3. Run the following command to install FFmpeg:
209
+
210
+ ```bash
211
+ choco install ffmpeg
212
+ ```
213
+
214
+ 4. After the installation is complete, verify that FFmpeg is correctly installed by running the following command:
215
+
216
+ ```bash
217
+ ffmpeg -version
218
+ ```
219
+
220
+ If the installation was successful, you should see the version information for FFmpeg.
221
+
222
+ Now you're ready to use FFmpeg in the script!
223
+
224
+ ---
225
+
226
+ ## 5. One Click Card Creation
227
+
228
+ This is the flagship feature of this script, so here is a section explaining it. It is possible to do full 1-click card
229
+ creation with this tool + Yomitan. The relevant settings are located in `Features` and `OBS` section in the config.
230
+
231
+ Demo: https://www.youtube.com/watch?v=9dmmXO2CGNw
232
+
233
+ Screenshots to help with setup:
234
+
235
+ ![image](https://github.com/user-attachments/assets/7de031e9-ce28-42eb-a8fd-0e60ef70dc3d)
236
+
237
+ ![image](https://github.com/user-attachments/assets/b0c70a1a-65b5-4fe7-a7e4-ccb0b9a5b249)
238
+
239
+ ![image](https://github.com/user-attachments/assets/4cf492eb-12a2-429f-aa0e-f87fc0fa6270)
240
+
241
+ ## 6. Example Process
242
+
243
+ 1. Start game
244
+ 2. Hook Game with Agent (or textractor) with clipboard enabled
245
+ 3. start script: `python main.py`
246
+ 1. Create Anki Card with target word (through a texthooker page/Yomitan)
247
+ 2. (If full-auto-mode not on) Trigger Hotkey to record replay buffer
248
+ 4. When finished gaming, end script
249
+
250
+ Once the hotkey is triggered:
251
+
252
+ 1. **OBS** will save the last X seconds of gameplay.
253
+ 2. The Python script will trim the audio based on last clipboard event, and the end of voiceline detected in Vosk if
254
+ enabled.
255
+ 3. Will attempt to update the LAST anki card created.
256
+
257
+ ---
258
+
259
+ ## How to Update the Script
260
+
261
+ ### Updater (Preferred)
262
+
263
+ There is now an Update script included! running `python update.py` in the directory will attempt to update your scripts
264
+ to the latest release. If you have made changes to any of the files, they will be safely backed up before being
265
+ replaced.
266
+
267
+ ---
268
+
269
+ ### Manual
270
+
271
+ To ensure you always have the latest version of this script, you can use `git pull` to update your local repository with
272
+ the latest changes from the remote repository.
273
+
274
+ #### Step-by-Step Instructions
275
+
276
+ 1. Open your terminal and navigate to the directory where you cloned the repository:
277
+ ```bash
278
+ cd path/to/script
279
+ ```
280
+
281
+ 2. Run the following command to fetch and integrate the latest changes:
282
+ ```bash
283
+ git pull origin main
284
+ ```
285
+
286
+ - **`origin`** refers to the remote repository from which you cloned the code.
287
+ - **`main`** refers to the main branch of the repository. If your default branch has a different name (
288
+ e.g., `master` or `dev`), replace `main` with that branch name.
289
+
290
+ 3. The `git pull` command will download and apply any updates from the remote repository to your local version.
291
+
292
+ ### Example:
293
+
294
+ ```bash
295
+ $ cd path/to/script
296
+ $ git pull origin master
297
+ ```
298
+
299
+ ---
300
+
301
+ ## Contact
302
+
303
+ If you run into issues ask in my [discord](https://discord.gg/yP8Qse6bb8), or make an issue here.
304
+
305
+ ## Donations
306
+
307
+ If you've benefited from this or any of my other projects, please consider supporting my work
308
+ via [Github Sponsors](https://github.com/sponsors/bpwhelan) or [Ko-fi.](https://ko-fi.com/beangate)