Delete microphone.py

This commit is contained in:
not-matt 2017-12-18 20:51:54 +00:00 committed by GitHub
parent 5bb5224158
commit 5eb369ae52
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,32 +0,0 @@
import time
import numpy as np
import pyaudio
import config
def start_stream(callback):
p = pyaudio.PyAudio()
frames_per_buffer = int(config.MIC_RATE / config.FPS)
stream = p.open(format=pyaudio.paInt16,
channels=1,
rate=config.MIC_RATE,
input=True,
frames_per_buffer=frames_per_buffer)
overflows = 0
prev_ovf_time = time.time()
while True:
try:
y = np.fromstring(stream.read(frames_per_buffer), dtype=np.int16)
y = y.astype(np.float32)
callback(y)
except IOError:
overflows += 1
if time.time() > prev_ovf_time + 1:
prev_ovf_time = time.time()
if config.USE_GUI:
gui.label_error.setText('Audio buffer has overflowed {} times'.format(overflows))
else:
print('Audio buffer has overflowed {} times'.format(overflows))
stream.stop_stream()
stream.close()
p.terminate()