audio-reactive-led-strip/python/microphone.py
Scott Lawson 028500f04e Initial commit
Initial commit of working python and ESP8266 code.
2016-10-12 14:50:00 -07:00

20 lines
405 B
Python

import pyaudio
RATE = 44100
FPS = 40
CHUNK = int(RATE / FPS)
def start_stream(callback):
p = pyaudio.PyAudio()
stream = p.open(format=pyaudio.paInt16,
channels=1,
rate=RATE,
input=True,
frames_per_buffer=CHUNK)
while True:
callback(stream)
stream.stop_stream()
stream.close()
p.terminate()