GameSentenceMiner 2.9.4__py3-none-any.whl → 2.9.5__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.
Files changed (42) hide show
  1. GameSentenceMiner/ai/ai_prompting.py +3 -3
  2. GameSentenceMiner/anki.py +16 -14
  3. GameSentenceMiner/config_gui.py +22 -7
  4. GameSentenceMiner/gametext.py +5 -5
  5. GameSentenceMiner/gsm.py +26 -67
  6. GameSentenceMiner/obs.py +7 -8
  7. GameSentenceMiner/ocr/owocr_area_selector.py +1 -1
  8. GameSentenceMiner/ocr/owocr_helper.py +30 -13
  9. GameSentenceMiner/owocr/owocr/ocr.py +0 -2
  10. GameSentenceMiner/owocr/owocr/run.py +1 -1
  11. GameSentenceMiner/{communication → util/communication}/__init__.py +1 -1
  12. GameSentenceMiner/{communication → util/communication}/send.py +1 -1
  13. GameSentenceMiner/{communication → util/communication}/websocket.py +2 -2
  14. GameSentenceMiner/{downloader → util/downloader}/download_tools.py +3 -3
  15. GameSentenceMiner/vad.py +344 -0
  16. GameSentenceMiner/web/texthooking_page.py +15 -10
  17. {gamesentenceminer-2.9.4.dist-info → gamesentenceminer-2.9.5.dist-info}/METADATA +2 -3
  18. gamesentenceminer-2.9.5.dist-info/RECORD +57 -0
  19. GameSentenceMiner/configuration.py +0 -647
  20. GameSentenceMiner/electron_config.py +0 -315
  21. GameSentenceMiner/ffmpeg.py +0 -441
  22. GameSentenceMiner/model.py +0 -177
  23. GameSentenceMiner/notification.py +0 -126
  24. GameSentenceMiner/package.py +0 -38
  25. GameSentenceMiner/ss_selector.py +0 -121
  26. GameSentenceMiner/text_log.py +0 -186
  27. GameSentenceMiner/util.py +0 -262
  28. GameSentenceMiner/vad/__init__.py +0 -0
  29. GameSentenceMiner/vad/groq_trim.py +0 -82
  30. GameSentenceMiner/vad/result.py +0 -21
  31. GameSentenceMiner/vad/silero_trim.py +0 -52
  32. GameSentenceMiner/vad/vad_utils.py +0 -13
  33. GameSentenceMiner/vad/vosk_helper.py +0 -158
  34. GameSentenceMiner/vad/whisper_helper.py +0 -105
  35. gamesentenceminer-2.9.4.dist-info/RECORD +0 -72
  36. /GameSentenceMiner/{downloader → util/downloader}/Untitled_json.py +0 -0
  37. /GameSentenceMiner/{downloader → util/downloader}/__init__.py +0 -0
  38. /GameSentenceMiner/{downloader → util/downloader}/oneocr_dl.py +0 -0
  39. {gamesentenceminer-2.9.4.dist-info → gamesentenceminer-2.9.5.dist-info}/WHEEL +0 -0
  40. {gamesentenceminer-2.9.4.dist-info → gamesentenceminer-2.9.5.dist-info}/entry_points.txt +0 -0
  41. {gamesentenceminer-2.9.4.dist-info → gamesentenceminer-2.9.5.dist-info}/licenses/LICENSE +0 -0
  42. {gamesentenceminer-2.9.4.dist-info → gamesentenceminer-2.9.5.dist-info}/top_level.txt +0 -0
@@ -1,105 +0,0 @@
1
- import tempfile
2
- import warnings
3
-
4
- import stable_whisper as whisper
5
- import torch
6
- from stable_whisper import WhisperResult
7
-
8
- from GameSentenceMiner import configuration, ffmpeg
9
- from GameSentenceMiner.configuration import *
10
- from GameSentenceMiner.vad.result import VADResult
11
-
12
- ffmpeg_base_command_list = ["ffmpeg", "-hide_banner", "-loglevel", "error"]
13
- whisper_model = None
14
-
15
-
16
- # Function to download and load the Whisper model
17
- def load_whisper_model():
18
- global whisper_model
19
- if whisper_model is None:
20
- with warnings.catch_warnings(action="ignore"):
21
- whisper_model = whisper.load_model(get_config().vad.whisper_model)
22
- logger.info(f"Whisper model '{get_config().vad.whisper_model}' loaded.")
23
-
24
-
25
- # Use Whisper to detect voice activity with timestamps in the audio
26
- def detect_voice_with_whisper(input_audio):
27
- # Convert the audio to 16kHz mono WAV
28
- temp_wav = tempfile.NamedTemporaryFile(dir=configuration.get_temporary_directory(), suffix='.wav').name
29
- ffmpeg.convert_audio_to_wav(input_audio, temp_wav)
30
-
31
- # Make sure Whisper is loaded
32
- load_whisper_model()
33
-
34
- logger.info('transcribing audio...')
35
-
36
- # Transcribe the audio using Whisper
37
- with warnings.catch_warnings(action="ignore"):
38
- result: WhisperResult = whisper_model.transcribe(temp_wav, vad=True, language=get_config().vad.language, temperature=0.0)
39
- voice_activity = []
40
-
41
- logger.debug(result.to_dict())
42
-
43
- # Process the segments to extract tokens, timestamps, and confidence
44
- for segment in result.segments:
45
- logger.debug(segment.to_dict())
46
- for word in segment.words:
47
- logger.debug(word.to_dict())
48
- confidence = word.probability
49
- if confidence > .1:
50
- logger.debug(word)
51
- voice_activity.append({
52
- 'text': word.word,
53
- 'start': word.start,
54
- 'end': word.end,
55
- 'confidence': word.probability
56
- })
57
-
58
- # Analyze the detected words to decide whether to use the audio
59
- should_use = False
60
- unique_words = set(word['text'] for word in voice_activity)
61
- if len(unique_words) > 1 or not all(item in ['えー', 'ん'] for item in unique_words):
62
- should_use = True
63
-
64
- if not should_use:
65
- return None
66
-
67
- # Return the detected voice activity and the total duration
68
- return voice_activity
69
-
70
-
71
- # Example usage of Whisper with trimming
72
- def process_audio_with_whisper(input_audio, output_audio, game_line):
73
- voice_activity = detect_voice_with_whisper(input_audio)
74
-
75
- if not voice_activity:
76
- logger.info("No voice activity detected in the audio.")
77
- return VADResult(False, 0, 0, WHISPER)
78
-
79
- # Trim based on the first and last speech detected
80
- start_time = voice_activity[0]['start'] if voice_activity else 0
81
- # if (game_line.next and len(voice_activity) > 1
82
- # and voice_activity[-1]['start'] - get_config().audio.beginning_offset > len(input_audio) / 16000
83
- # and (voice_activity[-1]['start'] - voice_activity[-2]['end']) > 5.0):
84
- # end_time = voice_activity[-2]['end']
85
- # logger.info("Using the second last timestamp for trimming")
86
- # else:
87
- end_time = voice_activity[-1]['end'] if voice_activity else 0
88
-
89
- if get_config().vad.trim_beginning:
90
- logger.info(f"VAD Trimmed Beginning of Audio to {start_time}")
91
-
92
- # Print detected speech details with timestamps
93
- logger.info(f"VAD Trimmed End of Audio to {end_time} seconds:")
94
-
95
- # Trim the audio using FFmpeg
96
- ffmpeg.trim_audio(input_audio, start_time + get_config().vad.beginning_offset, end_time + get_config().audio.end_offset, output_audio)
97
- return VADResult(True, start_time + get_config().vad.beginning_offset, end_time + get_config().audio.end_offset, WHISPER)
98
-
99
-
100
- # Load Whisper model initially
101
- def initialize_whisper_model():
102
- load_whisper_model()
103
-
104
- # initialize_whisper_model()
105
- # process_audio_with_whisper("tmp6x81cy27.opus", "tmp6x81cy27_trimmed.opus", None)
@@ -1,72 +0,0 @@
1
- GameSentenceMiner/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- GameSentenceMiner/anki.py,sha256=HAYblBjkth5p0tx9Z0LNQn6zuQC8_54RIB2BMzN8-LE,14705
3
- GameSentenceMiner/config_gui.py,sha256=h4zz85gfhxSphaJ-IZSu9D4jR70mDlKecZ9JRCO5Noc,80927
4
- GameSentenceMiner/configuration.py,sha256=KKW6fmpxya4dmXx9cERFVrzsKCTw0vmZrF2HAJDURBU,25667
5
- GameSentenceMiner/electron_config.py,sha256=dGcPYCISPehXubYSzsDuI2Gl092MYK0u3bTnkL9Jh1Y,9787
6
- GameSentenceMiner/ffmpeg.py,sha256=APa2vNdAgxYdG96_Z3Xdh1WqOiWaK6gTLJqzEvCMMeU,18323
7
- GameSentenceMiner/gametext.py,sha256=sll-6Pficd4ZXYy8yL8hBrEOSpfa53TOye7vtHHKFN4,6218
8
- GameSentenceMiner/gsm.py,sha256=olG3BIWjbVHWTsRKmeDVE5X8XrgppWke73Fy1J15dxA,29868
9
- GameSentenceMiner/model.py,sha256=1lRyJFf_LND_4O16h8CWVqDfosLgr0ZS6ufBZ3qJHpY,5699
10
- GameSentenceMiner/notification.py,sha256=e6TOzZJD7RTvMgxaY-V01r5OiocHhdqEIVdAnj4MGSw,3437
11
- GameSentenceMiner/obs.py,sha256=JiydRMpfSpNZ0nDAzH8OOECbYbsxMNSGz46lO8lZbvA,14871
12
- GameSentenceMiner/package.py,sha256=uu3Yb3pqu8vN5ISzP87YCHlFNR9wxMMf5hPRncTr7ws,1181
13
- GameSentenceMiner/ss_selector.py,sha256=csey9H3561-guRJcT6gQN6hXxvylP0CBI0dp2-kwo2Q,4446
14
- GameSentenceMiner/text_log.py,sha256=U2_g8THAYeexRiE2bLk_bCt_2ShiA8SQ9VdJsi4riHs,5181
15
- GameSentenceMiner/util.py,sha256=ZbK7i1UeOzKyc5WtCcttiGljR_stfu7qpnEpgqFBwro,8976
16
- GameSentenceMiner/ai/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
17
- GameSentenceMiner/ai/ai_prompting.py,sha256=xw8et6XNwQiDXOXZnw8iIntVSg8lni4YYZbgWsK7qDE,10013
18
- GameSentenceMiner/assets/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
19
- GameSentenceMiner/assets/icon.png,sha256=9GRL8uXUAgkUSlvbm9Pv9o2poFVRGdW6s2ub_DeUD9M,937624
20
- GameSentenceMiner/assets/icon128.png,sha256=l90j7biwdz5ahwOd5wZ-406ryEV9Pan93dquJQ3e1CI,18395
21
- GameSentenceMiner/assets/icon256.png,sha256=JEW46wOrG1KR-907rvFaEdNbPtj5gu0HJmG7qUnIHxQ,51874
22
- GameSentenceMiner/assets/icon32.png,sha256=Kww0hU_qke9_22wBuO_Nq0Dv2SfnOLwMhCyGgbgXdg8,6089
23
- GameSentenceMiner/assets/icon512.png,sha256=HxUj2GHjyQsk8NV433256UxU9phPhtjCY-YB_7W4sqs,192487
24
- GameSentenceMiner/assets/icon64.png,sha256=N8xgdZXvhqVQP9QUK3wX5iqxX9LxHljD7c-Bmgim6tM,9301
25
- GameSentenceMiner/assets/pickaxe.png,sha256=VfIGyXyIZdzEnVcc4PmG3wszPMO1W4KCT7Q_nFK6eSE,1403829
26
- GameSentenceMiner/communication/__init__.py,sha256=_jGn9PJxtOAOPtJ2rI-Qu9hEHVZVpIvWlxKvqk91_zI,638
27
- GameSentenceMiner/communication/send.py,sha256=X0MytGv5hY-uUvkfvdCqQA_ljZFmV6UkJ6in1TA1bUE,217
28
- GameSentenceMiner/communication/websocket.py,sha256=8eFZaTtoFggEPdqw2Jl4zqHC2I7J3-Gk27CxVX7SyBo,3277
29
- GameSentenceMiner/downloader/Untitled_json.py,sha256=RUUl2bbbCpUDUUS0fP0tdvf5FngZ7ILdA_J5TFYAXUQ,15272
30
- GameSentenceMiner/downloader/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
31
- GameSentenceMiner/downloader/download_tools.py,sha256=aRfpCqEmKUFRVsGipwY-7PhY6AeWiFJanW4ZCB9e2iE,8124
32
- GameSentenceMiner/downloader/oneocr_dl.py,sha256=o3ANp5IodEQoQ8GPcJdg9Y8JzA_lictwnebFPwwUZVk,10144
33
- GameSentenceMiner/ocr/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
34
- GameSentenceMiner/ocr/gsm_ocr_config.py,sha256=fEQ2o2NXksGRHpueO8c4TfAp75GEdAtAr1ngTFOsdpg,2257
35
- GameSentenceMiner/ocr/ocrconfig.py,sha256=_tY8mjnzHMJrLS8E5pHqYXZjMuLoGKYgJwdhYgN-ny4,6466
36
- GameSentenceMiner/ocr/owocr_area_selector.py,sha256=Q8ETMHL7BKMA1mbtjrntDLyqCQB0lZ5T4RCZsodjH7Y,47186
37
- GameSentenceMiner/ocr/owocr_helper.py,sha256=M4Is-Ki5O3r4ixYhILibfjrVGD6xDlOcR3YvVGmETQ4,17363
38
- GameSentenceMiner/owocr/owocr/__init__.py,sha256=opjBOyGGyEqZCE6YdZPnyt7nVfiwyELHsXA0jAsjm14,25
39
- GameSentenceMiner/owocr/owocr/__main__.py,sha256=XQaqZY99EKoCpU-gWQjNbTs7Kg17HvBVE7JY8LqIE0o,157
40
- GameSentenceMiner/owocr/owocr/config.py,sha256=qM7kISHdUhuygGXOxmgU6Ef2nwBShrZtdqu4InDCViE,8103
41
- GameSentenceMiner/owocr/owocr/lens_betterproto.py,sha256=oNoISsPilVVRBBPVDtb4-roJtAhp8ZAuFTci3TGXtMc,39141
42
- GameSentenceMiner/owocr/owocr/ocr.py,sha256=V0HqVRQlaE1-12IH480IupfSv1BlDdEcwNPejhQZfS0,42292
43
- GameSentenceMiner/owocr/owocr/run.py,sha256=0UyjOKEP0MqSdCaagCUMGdqO-BMexPxCl7ZabGlic4E,54749
44
- GameSentenceMiner/owocr/owocr/screen_coordinate_picker.py,sha256=Na6XStbQBtpQUSdbN3QhEswtKuU1JjReFk_K8t5ezQE,3395
45
- GameSentenceMiner/vad/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
46
- GameSentenceMiner/vad/groq_trim.py,sha256=MDYiApduwF7oDx3r0TXL3xQrTkbUC1RinMwNKSbF5gw,3764
47
- GameSentenceMiner/vad/result.py,sha256=aFlr2px90fn3qXj49dwF9BDXA5m4yXD_HYH01CVvP1U,799
48
- GameSentenceMiner/vad/silero_trim.py,sha256=u4BC93LieJW0CZ7HToz51FneojqW_SNjSKmJmHMKwUA,2240
49
- GameSentenceMiner/vad/vad_utils.py,sha256=_YC6rW2eXSBeLnYbVl_F3na1KCRL90VrnOzKYJ9RhUE,391
50
- GameSentenceMiner/vad/vosk_helper.py,sha256=h7yNHrzrzT-J74UniA0T2ZX8cHqhflCzwyDjoIdKLO4,6479
51
- GameSentenceMiner/vad/whisper_helper.py,sha256=B64-Eq_ZMCIyQX_A8uvYz-c48hSXJAyz6tSXNRaLjtA,4020
52
- GameSentenceMiner/web/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
53
- GameSentenceMiner/web/texthooking_page.py,sha256=7Z7TGDcnj-94Y9ws7bQph4oIXrqf8Q9qVKowKimHWxM,14749
54
- GameSentenceMiner/web/static/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
55
- GameSentenceMiner/web/static/apple-touch-icon.png,sha256=OcMI8af_68DA_tweOsQ5LytTyMwm7-hPW07IfrOVgEs,46132
56
- GameSentenceMiner/web/static/favicon-96x96.png,sha256=lOePzjiKl1JY2J1kT_PMdyEnrlJmi5GWbmXJunM12B4,16502
57
- GameSentenceMiner/web/static/favicon.ico,sha256=7d25r_FBqRSNsAoEHpSzNoT7zyVt2DJRLNDNq_HYoX8,15086
58
- GameSentenceMiner/web/static/favicon.svg,sha256=x305AP6WlXGtrXIZlaQspdLmwteoFYUoe5FyJ9MYlJ8,11517
59
- GameSentenceMiner/web/static/site.webmanifest,sha256=kaeNT-FjFt-T7JGzOhXH7YSqsrDeiplZ2kDxCN_CFU4,436
60
- GameSentenceMiner/web/static/style.css,sha256=bPZK0NVMuyRl5NNDuT7ZTzVLKlvSsdmeVHmAW4y5FM0,7001
61
- GameSentenceMiner/web/static/web-app-manifest-192x192.png,sha256=EfSNnBmsSaLfESbkGfYwbKzcjKOdzuWo18ABADfN974,51117
62
- GameSentenceMiner/web/static/web-app-manifest-512x512.png,sha256=wyqgCWCrLEUxSRXmaA3iJEESd-vM-ZmlTtZFBY4V8Pk,230819
63
- GameSentenceMiner/web/templates/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
64
- GameSentenceMiner/web/templates/index.html,sha256=HZKiIjiGJV8PGQ9T2aLDUNSfJn71qOwbYCjbRuSIjpY,213583
65
- GameSentenceMiner/web/templates/text_replacements.html,sha256=tV5c8mCaWSt_vKuUpbdbLAzXZ3ATZeDvQ9PnnAfqY0M,8598
66
- GameSentenceMiner/web/templates/utility.html,sha256=3flZinKNqUJ7pvrZk6xu__v67z44rXnaK7UTZ303R-8,16946
67
- gamesentenceminer-2.9.4.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
68
- gamesentenceminer-2.9.4.dist-info/METADATA,sha256=jNhOj4IaiTEJqGlm4-VCtviW5hmN8J5XnvPBGWgcY0Y,7280
69
- gamesentenceminer-2.9.4.dist-info/WHEEL,sha256=zaaOINJESkSfm_4HQVc5ssNzHCPXhJm0kEUakpsEHaU,91
70
- gamesentenceminer-2.9.4.dist-info/entry_points.txt,sha256=2APEP25DbfjSxGeHtwBstMH8mulVhLkqF_b9bqzU6vQ,65
71
- gamesentenceminer-2.9.4.dist-info/top_level.txt,sha256=V1hUY6xVSyUEohb0uDoN4UIE6rUZ_JYx8yMyPGX4PgQ,18
72
- gamesentenceminer-2.9.4.dist-info/RECORD,,