Implement Noisegate function to start and stop playing the audio stream

This commit is contained in:
Logan Cusano
2022-02-04 12:35:00 -05:00
parent 329dc8fff8
commit 0cac9c8f81
4 changed files with 129 additions and 70 deletions

View File

@@ -1,5 +1,6 @@
import sounddevice as sd
from pprint import pformat
from NoiseGate import NoiseGate
DEFAULT = 0
sd.default.channels = 2
@@ -7,10 +8,14 @@ sd.default.dtype = "int16"
sd.default.latency = "low"
sd.default.samplerate = 48000
noisegate_obj = NoiseGate()
class PCMStream:
def __init__(self):
globals()
def __init__(self, voice_connection):
self.stream = None
self.voice_connection = voice_connection
def read(self, num_bytes):
# frame is 4 bytes
@@ -26,7 +31,10 @@ class PCMStream:
self.stream.close()
self.stream = sd.RawInputStream(device=num)
noisegate_obj.init_stream(num, self.voice_connection, self)
self.stream.start()
noisegate_obj.start()
class DeviceNotFoundError(Exception):