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

View File

@@ -1,3 +1,4 @@
import threading
import time
import numpy as np
@@ -9,12 +10,14 @@ noise_gate_trigger = 0 # Set this value for the trigger on the noise-gate
voice_connection = None
audio_stream = None
class NoiseGate(Thread):
def __init__(self, trigger_value: int = 1000):
global noise_gate_trigger
super(NoiseGate, self).__init__()
self.stream = None
self.stop_NG = threading.Event()
self.NG_Started = threading.Event()
noise_gate_trigger = trigger_value
def init_stream(self, num, _voice_connection, _audio_stream):
@@ -24,7 +27,14 @@ class NoiseGate(Thread):
audio_stream = _audio_stream
def run(self) -> None:
self.stream.start()
while not self.stop_NG.is_set():
self.NG_Started.set()
self.stream.start()
self.stream.stop()
self.stream.close()
self.NG_Started.clear()
print('Thread #%s stopped' % self.ident)
def stream_callback(indata, *args):
@@ -40,4 +50,4 @@ def stream_callback(indata, *args):
if voice_connection.is_playing():
print("Noise Gate stopped")
voice_connection.stop()
# try disconnecting and reconnecting
# try disconnecting and reconnecting