kenenet 0.7.6__py3-none-any.whl → 0.7.9__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.
- kenenet/__init__.py +73 -11
- {kenenet-0.7.6.dist-info → kenenet-0.7.9.dist-info}/METADATA +1 -1
- kenenet-0.7.9.dist-info/RECORD +5 -0
- kenenet-0.7.6.dist-info/RECORD +0 -5
- {kenenet-0.7.6.dist-info → kenenet-0.7.9.dist-info}/WHEEL +0 -0
- {kenenet-0.7.6.dist-info → kenenet-0.7.9.dist-info}/top_level.txt +0 -0
kenenet/__init__.py
CHANGED
@@ -3,6 +3,13 @@ import numpy as np
|
|
3
3
|
from PIL import Image
|
4
4
|
from pydub import AudioSegment
|
5
5
|
from pydub.playback import play
|
6
|
+
import random
|
7
|
+
import threading
|
8
|
+
import pyaudio
|
9
|
+
import time
|
10
|
+
from pydub import AudioSegment
|
11
|
+
from zhmiscellany._processing_supportfuncs import _ray_init_thread
|
12
|
+
import zhmiscellany.processing
|
6
13
|
global timings, ospid, debug_mode
|
7
14
|
ospid, debug_mode = None, False
|
8
15
|
timings = {}
|
@@ -104,16 +111,12 @@ class _VariableTracker:
|
|
104
111
|
def _track_frame(frame, event, arg):
|
105
112
|
tracker = _VariableTracker._get_instance()
|
106
113
|
if not tracker.active or event != 'line': return _track_frame
|
107
|
-
|
108
114
|
# Skip tracking if function name is 'quick_print'
|
109
115
|
if frame.f_code.co_name == 'quick_print':
|
110
116
|
return _track_frame
|
111
|
-
|
112
117
|
scope = "Global" if frame.f_code.co_name == '<module>' else f"Local in '{frame.f_code.co_name}'"
|
113
118
|
current_vars = {name: value for name, value in (frame.f_locals if scope != "Global" else frame.f_globals).items() if tracker._should_track(name)}
|
114
|
-
|
115
119
|
line_number = frame.f_lineno # Capture the line number where the change occurred
|
116
|
-
|
117
120
|
if scope == "Global":
|
118
121
|
for name, value in current_vars.items():
|
119
122
|
if name not in tracker.global_vars:
|
@@ -191,14 +194,73 @@ def save_img(img, name=' ', reset=True, file='temp_screenshots', mute=False):
|
|
191
194
|
else:
|
192
195
|
quick_print(f"Your img is not a fucking numpy array you twat, couldn't save {name}", lineno)
|
193
196
|
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
+
|
198
|
+
class AudioPlayer:
|
199
|
+
def __init__(self, file):
|
200
|
+
self.file = file
|
201
|
+
self.active_audio = {}
|
197
202
|
|
198
|
-
def
|
199
|
-
|
200
|
-
|
201
|
-
|
203
|
+
def _stream_audio(self, sound, stop_event, chunk=1024):
|
204
|
+
p = pyaudio.PyAudio()
|
205
|
+
stream = p.open(
|
206
|
+
format=p.get_format_from_width(sound.sample_width),
|
207
|
+
channels=sound.channels,
|
208
|
+
rate=sound.frame_rate,
|
209
|
+
output=True
|
210
|
+
)
|
211
|
+
raw_data = sound.raw_data
|
212
|
+
for i in range(0, len(raw_data), chunk):
|
213
|
+
if stop_event.is_set():
|
214
|
+
break
|
215
|
+
stream.write(raw_data[i:i + chunk])
|
216
|
+
|
217
|
+
stream.stop_stream()
|
218
|
+
stream.close()
|
219
|
+
p.terminate()
|
220
|
+
|
221
|
+
class _AudioLooper:
|
222
|
+
def __init__(self, sound, stop_event, stream_func, loop=True):
|
223
|
+
self.sound = sound
|
224
|
+
self.loop = loop
|
225
|
+
self.stop_event = stop_event
|
226
|
+
self.stream_func = stream_func
|
227
|
+
self.thread = threading.Thread(target=self._loop_audio, name="AudioLooperThread", daemon=True)
|
228
|
+
self.thread.start()
|
229
|
+
|
230
|
+
def _loop_audio(self):
|
231
|
+
while not self.stop_event.is_set():
|
232
|
+
self.stream_func(self.sound, self.stop_event)
|
233
|
+
if not self.loop:
|
234
|
+
break
|
235
|
+
|
236
|
+
def stop(self):
|
237
|
+
self.stop_event.set()
|
238
|
+
self.thread.join()
|
239
|
+
|
240
|
+
def play(self, loop=False, range=(0.9, 1.1)):
|
241
|
+
file_sound = AudioSegment.from_mp3(self.file)._spawn(
|
242
|
+
AudioSegment.from_mp3(self.file).raw_data,
|
243
|
+
overrides={'frame_rate': int(AudioSegment.from_mp3(self.file).frame_rate * random.uniform(*range))}
|
244
|
+
)
|
245
|
+
stop_event = threading.Event()
|
246
|
+
looper = self._AudioLooper(file_sound, stop_event, self._stream_audio, loop=loop)
|
247
|
+
self.active_audio[id(file_sound)] = looper
|
248
|
+
|
249
|
+
def stop(self, file_sound=None):
|
250
|
+
if file_sound:
|
251
|
+
file_sound_id = id(file_sound)
|
252
|
+
if file_sound_id in self.active_audio:
|
253
|
+
self.active_audio[file_sound_id].stop()
|
254
|
+
del self.active_audio[file_sound_id]
|
255
|
+
else:
|
256
|
+
for looper in self.active_audio.values():
|
257
|
+
looper.stop()
|
258
|
+
self.active_audio.clear()
|
259
|
+
|
260
|
+
|
261
|
+
def load_audio(mp3_path):
|
262
|
+
_ray_init_thread.join()
|
263
|
+
return zhmiscellany.processing.synchronous_class_multiprocess(AudioPlayer, mp3_path)
|
202
264
|
|
203
265
|
class k:
|
204
266
|
pass
|
@@ -0,0 +1,5 @@
|
|
1
|
+
kenenet/__init__.py,sha256=gm2KeCvfhCSb_bytoZ8kD-F3-K-0tzswxrKkhWMEeAQ,10779
|
2
|
+
kenenet-0.7.9.dist-info/METADATA,sha256=tnQtMyZv3_uO06omh5LMmu65ecMuM0Vj-Bah_JOSQLk,633
|
3
|
+
kenenet-0.7.9.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
|
4
|
+
kenenet-0.7.9.dist-info/top_level.txt,sha256=gUsWXLrM0jF4b4nbYJZdksdFewIx_F3xOF-zER8fMuQ,8
|
5
|
+
kenenet-0.7.9.dist-info/RECORD,,
|
kenenet-0.7.6.dist-info/RECORD
DELETED
@@ -1,5 +0,0 @@
|
|
1
|
-
kenenet/__init__.py,sha256=s9WjOqwz1eFJavKeSxMovDdwSnAm2w2NygQR0fxmxY0,8572
|
2
|
-
kenenet-0.7.6.dist-info/METADATA,sha256=0MHlsOHGA33WK1sD0ERF2K0qjBNYqGnBdeCGzZwTVvI,633
|
3
|
-
kenenet-0.7.6.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
|
4
|
-
kenenet-0.7.6.dist-info/top_level.txt,sha256=gUsWXLrM0jF4b4nbYJZdksdFewIx_F3xOF-zER8fMuQ,8
|
5
|
-
kenenet-0.7.6.dist-info/RECORD,,
|
File without changes
|
File without changes
|