this doesn't work yet. May never work lol.
This commit is contained in:
0
modules/__init__.py
Normal file
0
modules/__init__.py
Normal file
28
modules/custom_mumble.py
Normal file
28
modules/custom_mumble.py
Normal file
@ -0,0 +1,28 @@
|
||||
import pymumble_py3
|
||||
import numpy as np
|
||||
import threading
|
||||
|
||||
|
||||
class CustomMumble(pymumble_py3.Mumble):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.audio_handler = None
|
||||
self.is_running = False
|
||||
|
||||
def set_audio_handler(self, audio_handler):
|
||||
self.audio_handler = audio_handler
|
||||
|
||||
def sound_received_handler(self, user, soundchunk):
|
||||
if self.audio_handler is not None:
|
||||
sound_array = np.frombuffer(soundchunk.pcm, dtype=np.int16)
|
||||
num_channels = self.audio_handler.channels
|
||||
sound_array = sound_array.reshape((-1, num_channels))
|
||||
sound_float = sound_array.astype(np.float32) / 32767.0
|
||||
self.audio_handler.write(sound_float)
|
||||
|
||||
def start(self):
|
||||
self.is_running = True
|
||||
threading.Thread(target=self.run).start()
|
||||
|
||||
def stop(self):
|
||||
self.is_running = False
|
Reference in New Issue
Block a user