diff --git a/bot.py b/bot.py index bf1f148..e92f657 100644 --- a/bot.py +++ b/bot.py @@ -88,10 +88,13 @@ class Bot(commands.Bot): voice_connection = await channel.connect() # Create an audio stream from selected device - self.streamHandler = sound.PCMStream(voice_connection) + self.streamHandler = sound.PCMStream() # Ensure the selected device is available and start the audio stream self.streamHandler.change_device(self.DEVICE_ID) + # Play the stream + voice_connection.play(discord.PCMAudio(self.streamHandler)) + # Start the SDR and begin playing to the audio stream self.start_sdr() diff --git a/sound.py b/sound.py index bf0297f..c27ca36 100644 --- a/sound.py +++ b/sound.py @@ -1,6 +1,5 @@ import sounddevice as sd from pprint import pformat -from NoiseGate import NoiseGate DEFAULT = 0 sd.default.channels = 2 @@ -8,14 +7,11 @@ sd.default.dtype = "int16" sd.default.latency = "low" sd.default.samplerate = 48000 -noisegate_obj = NoiseGate() - class PCMStream: globals() - def __init__(self, voice_connection): + def __init__(self): self.stream = None - self.voice_connection = voice_connection def read(self, num_bytes): # frame is 4 bytes @@ -29,10 +25,8 @@ class PCMStream: self.clean_up() self.stream = sd.RawInputStream(device=device_ID) - noisegate_obj.init_stream(device_ID, self.voice_connection, self) self.stream.start() - noisegate_obj.start() def clean_up(self): global noisegate_obj @@ -40,13 +34,6 @@ class PCMStream: self.stream.stop() self.stream.close() - if noisegate_obj.NG_Started.is_set(): - print("Closing the noisegate") - noisegate_obj.stop_NG.set() - noisegate_obj.join() - noisegate_obj = NoiseGate() - print("Started the noisegate") - class DeviceNotFoundError(Exception): def __init__(self):