garmr/garmr.py

54 lines
1.3 KiB
Python
Executable File

#!/usr/bin/env python3
import pymumble_py3
from pymumble_py3.callbacks import PYMUMBLE_CLBK_SOUNDRECEIVED as PCS
import sounddevice as sd
import numpy as np
import threading
import time
from modules.custom_mumble import CustomMumble
from setproctitle import setproctitle
setproctitle("Garmr")
# Connection details for Mumble server
server = "mumble.example.com" # server address
nick = "Garmr_Test"
port = 64738 # port number
passwd = "" # password
# Audio settings
SAMPLE_RATE = 48000
CHANNELS = 2
# Create a Mumble client using the custom wrapper class
mumble = CustomMumble(server, nick, password=passwd, port=port)
mumble.set_application_string("garmr")
# Create a SoundDevice audio handler
audio_handler = sd.OutputStream(samplerate=SAMPLE_RATE, channels=CHANNELS)
# Set the audio handler in the custom Mumble class
mumble.set_audio_handler(audio_handler)
# Set up the sound received callback
mumble.callbacks.set_callback(PCS, mumble.sound_received_handler)
# Start the Mumble client
mumble.start()
mumble.is_ready() # Wait for the client to be ready
# Keep the script running until interrupted
try:
while True:
time.sleep(1)
except KeyboardInterrupt:
pass
finally:
# Stop the Mumble client
mumble.stop()
# Stop and close the SoundDevice stream
audio_handler.stop()
audio_handler.close()