BUGFIX noisegate

- Froze when leaving and joining
- Add aarch64 option for opus
This commit is contained in:
Logan Cusano
2022-02-06 18:45:25 -05:00
parent 181cbd9180
commit 8525f79878
3 changed files with 43 additions and 10 deletions

20
bot.py
View File

@@ -1,4 +1,5 @@
import os
import platform
import discord
import sound
import configparser
@@ -23,6 +24,9 @@ class Bot(commands.Bot):
self.Default_Mention_Group = kwargs['Mention_Group']
self.Handler = kwargs['Handler']
# Init Variable forsound
self.streamHandler = None
# Init the audio devices list
self.Devices_List = sound.query_devices().items()
@@ -82,9 +86,9 @@ class Bot(commands.Bot):
# Create an audio stream from selected device
stream = sound.PCMStream(voice_connection)
self.streamHandler = sound.PCMStream(voice_connection)
# Ensure the selected device is available and start the audio stream
stream.change_device(self.DEVICE_ID)
self.streamHandler.change_device(self.DEVICE_ID)
# Start the SDR and begin playing to the audio stream
self.start_sdr()
@@ -99,6 +103,8 @@ class Bot(commands.Bot):
@self.command(help="Use this command to have the bot leave your channel",
brief="Leaves the current voice channel")
async def leave(ctx):
# Stop the sound handlers
self.streamHandler.cleanup()
# Disconnect the client from the voice channel
await ctx.voice_client.disconnect()
# Change the presence to away and '@ me'
@@ -187,8 +193,10 @@ class Bot(commands.Bot):
def load_opus(self):
# Check the system type and load the correct library
if self.system_os_type == 'Linux':
if self.system_os_type == 'Linux_32':
discord.opus.load_opus('./opus/libopus.so')
elif self.system_os_type == 'Linux_64':
discord.opus.load_opus('./opus/libopus_aarcch64.so')
elif self.system_os_type == 'Windows':
discord.opus.load_opus('./opus/libopus.dll')
@@ -233,7 +241,11 @@ class Bot(commands.Bot):
if os.name == 'nt':
self.system_os_type = 'Windows'
else:
self.system_os_type = 'Linux'
processor = platform.architecture()[0]
if processor == "64bit":
self.system_os_type = 'Linux_64'
elif processor == "32bit":
self.system_os_type = 'Linux_32'
# Check to see if there is only one frequency
def start_sdr(self):