Fix prerol error always 1s

This commit is contained in:
Ruben van de Ven 2019-04-12 11:56:47 +02:00
parent c1c871a27f
commit a4acc04a91

View file

@ -49,12 +49,13 @@ class VoiceServer(object):
self.hugvey = hugvey
self.chunk = 4096
self.mic_prerol_sec = .05
self.prerol_frame_count = math.ceil(self.input_rate / self.chunk)
self.mic_prerol_sec = .2
self.prerol_frame_count = math.ceil((self.input_rate / self.chunk) * self.mic_prerol_sec)
self.prerol_frames = collections.deque(maxlen = self.prerol_frame_count)
self.p = pyaudio.PyAudio()
# wait a sec for the input devices to come up
logger.debug("Use a mic prerol of {} frames".format(self.prerol_frame_count))
logger.debug('wait for mic')
time.sleep(3)
logger.debug('done waiting for mic')