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