mirror of
https://github.com/SevaSk/ecoute.git
synced 2024-12-18 20:27:56 +00:00
only add to audio queue if we have data
This commit is contained in:
parent
8cb45bc023
commit
aa9557e13b
@ -1,3 +1,4 @@
|
||||
import numpy as np
|
||||
import soundcard as sc
|
||||
from Microphone import Microphone
|
||||
import pythoncom
|
||||
@ -13,5 +14,6 @@ class AudioRecorder:
|
||||
pythoncom.CoInitialize()
|
||||
with sc.get_microphone(id=self.microphone.id, include_loopback=self.microphone.loop_back).recorder(samplerate=SAMPLE_RATE) as mic:
|
||||
while True:
|
||||
data = mic.record(numframes=SAMPLE_RATE*RECORDING_TIME) # data is a frames x channels Numpy array.
|
||||
audio_queue.put((source, data))
|
||||
data = mic.record(numframes=SAMPLE_RATE*RECORDING_TIME)
|
||||
if np.any(data):
|
||||
audio_queue.put((source, data))
|
Loading…
Reference in New Issue
Block a user