Implement Noisegate function to start and stop playing the audio stream
This commit is contained in:
10
sound.py
10
sound.py
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user