--- a/snd.py +++ b/snd.py @@ -12,11 +12,15 @@ import threading from pydispatch import dispatcher -CHANNELS = 1 THRESHOLD = 500 CHUNK_SIZE = 1024 FORMAT = pyaudio.paInt16 RATE = 44100 +if sys.platform.startswith('darwin'): + CHANNELS = 2 +elif sys.platform.startswith('win32'): + CHANNELS = 1 + MAX_SILENT = 30 def is_silent(L): @@ -77,8 +81,8 @@ it without getting chopped off. """ p = pyaudio.PyAudio() - stream = p.open(format=FORMAT, channels=1, rate=RATE, - input=True, output=True, + stream = p.open(format=FORMAT, channels=CHANNELS, rate=RATE, + input=True, frames_per_buffer=CHUNK_SIZE) num_silent = 0