Added a callback to itself so if it cuts out, it should restart

This commit is contained in:
Logan Cusano
2022-03-31 02:28:54 -04:00
parent 9e60444bc6
commit 6efca8f0fa

View File

@@ -1,6 +1,8 @@
import audioop
import logging
import math
import time
import pyaudio
import discord
import numpy
@@ -118,14 +120,22 @@ class NoiseGate(AudioStream):
voice_connection = _voice_connection
self.THRESHOLD = _noise_gate_threshold
self.NGStream = NoiseGateStream(self)
self.Voice_Connection_Thread = None
def run(self) -> None:
global voice_connection
# Start the audio stream
LOGGER.debug(f"Starting stream")
self.stream.start_stream()
LOGGER.debug(f"Playing stream to discord")
voice_connection.play(self.NGStream)
# Start the stream to discord
self.core()
def core(self, error=None):
if error:
LOGGER.warning(error)
if not voice_connection.is_playing():
LOGGER.debug(f"Playing stream to discord")
voice_connection.play(self.NGStream, after=self.core)
async def close(self):
LOGGER.debug(f"Closing")