pymumble
pymumble copied to clipboard
Foir the echobot.py example, how would I send the bot to a certain channel and add a delay?
For this example: https://github.com/azlux/pymumble/blob/pymumble_py3/examples/echobot.py I'd like to have the bot move to an "audio test" channel on my mumble server and add a delay of about 10 seconds between the user's audio and the bot's repeated audio. Currently it sits in root and the echo is immediate. I'd like for this to help users test their audio before joining other rooms.
Based on echobot.py, free to go to the examples section:
For the echo delay, change echo_timer accordingly.
# This bot sends any sound it receives back to where it has come from.
# Based on echobot.py
import pymumble_py3
from pymumble_py3.callbacks import PYMUMBLE_CLBK_SOUNDRECEIVED as PCS
import time
pwd = ""
server = ""
port = 12345
nick = "Bob"
sound = {
"buffer": b"",
"last_time": 0.0,
"echo_timer": 0.5
}
def sound_received_handler(user, sound_chunk):
sound["buffer"] += sound_chunk.pcm
sound["last_time"] = time.time()
def sound_send():
print("sound buffer size:", len(sound["buffer"]))
mumble.sound_output.add_sound(sound["buffer"])
sound["buffer"] = b""
def echo_ready():
if sound["buffer"] != b"" and time.time() - sound["last_time"] >= sound["echo_timer"]:
return True
def init_mumble(channel="Root"):
_mumble = pymumble_py3.Mumble(server, nick, password=pwd, port=port)
_mumble.callbacks.set_callback(PCS, sound_received_handler)
_mumble.set_receive_sound(1)
_mumble.start()
_mumble.is_ready()
_mumble.channels.find_by_name(channel).move_in()
return _mumble
if __name__ == "__main__":
mumble = init_mumble(channel="Eingangshalle")
while 1:
time.sleep(0.2)
if echo_ready():
sound_send()