Moving PDAB to pdab
This commit is contained in:
75
Client/pdab/main.py
Normal file
75
Client/pdab/main.py
Normal file
@@ -0,0 +1,75 @@
|
||||
import argparse, platform, os
|
||||
from discord import Intents, Client, Member, opus
|
||||
from discord.ext import commands
|
||||
from NoiseGatev2 import NoiseGate
|
||||
|
||||
# Load the proper OPUS library for the device being used
|
||||
async def load_opus():
|
||||
# Check the system type and load the correct library
|
||||
# Linux ARM AARCH64 running 32bit OS
|
||||
processor = platform.machine()
|
||||
print("Processor: ", processor)
|
||||
if os.name == 'nt':
|
||||
if processor == "AMD64":
|
||||
print(f"Loaded OPUS library for AMD64")
|
||||
opus.load_opus('./opus/libopus_amd64.dll')
|
||||
return "AMD64"
|
||||
else:
|
||||
if processor == "aarch64":
|
||||
print(f"Loaded OPUS library for aarch64")
|
||||
opus.load_opus('./opus/libopus_aarcch64.so')
|
||||
return "aarch64"
|
||||
elif processor == "armv7l":
|
||||
print(f"Loaded OPUS library for armv7l")
|
||||
opus.load_opus('./opus/libopus_armv7l.so')
|
||||
return "armv7l"
|
||||
|
||||
|
||||
def main(clientId='OTQzNzQyMDQwMjU1MTE1MzA0.Yg3eRA.ZxEbRr55xahjfaUmPY8pmS-RHTY', channelId=367396189529833476, NGThreshold=50, deviceId=1):
|
||||
intents = Intents.default()
|
||||
|
||||
client = commands.Bot(command_prefix='!', intents=intents)
|
||||
|
||||
@client.event
|
||||
async def on_ready():
|
||||
print(f'We have logged in as {client.user}')
|
||||
|
||||
channelIdToJoin = client.get_channel(channelId)
|
||||
print("Channel", channelIdToJoin)
|
||||
|
||||
print("Loading opus")
|
||||
await load_opus()
|
||||
|
||||
if opus.is_loaded():
|
||||
print("Joining voice")
|
||||
channelConnection = await channelIdToJoin.connect(timeout=60.0, reconnect=True)
|
||||
print("Voice Connected")
|
||||
streamHandler = NoiseGate(
|
||||
_input_device_index=deviceId,
|
||||
_voice_connection=channelConnection,
|
||||
_noise_gate_threshold=NGThreshold)
|
||||
# Start the audio stream
|
||||
streamHandler.run()
|
||||
print("stream running")
|
||||
|
||||
|
||||
client.run(clientId)
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("deviceId", type=int, help="The ID of the audio device to use")
|
||||
parser.add_argument("channelId", type=int, help="The ID of the voice channel to use")
|
||||
parser.add_argument("clientId", type=str, help="The discord client ID")
|
||||
parser.add_argument("-n", "--NGThreshold", type=int, help="Change the noisegate threshold. This defaults to 50")
|
||||
args = parser.parse_args()
|
||||
|
||||
if (not args.NGThreshold):
|
||||
args.NGThreshold = 50
|
||||
|
||||
print("Arguments:", args)
|
||||
|
||||
main(
|
||||
clientId=args.clientId,
|
||||
channelId=args.channelId,
|
||||
NGThreshold=args.NGThreshold,
|
||||
deviceId=args.deviceId
|
||||
)
|
||||
Reference in New Issue
Block a user