From a4acc04a91d217188b41b066b67fe95f1e691b56 Mon Sep 17 00:00:00 2001 From: Ruben van de Ven Date: Fri, 12 Apr 2019 11:56:47 +0200 Subject: [PATCH] Fix prerol error always 1s --- hugvey/client.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/hugvey/client.py b/hugvey/client.py index 0f9fe28..3b5a6ef 100644 --- a/hugvey/client.py +++ b/hugvey/client.py @@ -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')