more osx fixes
--- a/scannr.py
+++ b/scannr.py
@@ -67,7 +67,7 @@
path = "./data/"+filename
dispatcher.send( signal='FILE_CREATED', sender=filename, filename=filename, length=len(data))
wf = wave.open(path, 'wb')
- wf.setnchannels(1)
+ wf.setnchannels(2)
wf.setsampwidth(sample_width)
wf.setframerate(snd.RATE)
wf.writeframes(data)
--- a/snd.py
+++ b/snd.py
@@ -17,11 +17,11 @@
FORMAT = pyaudio.paInt16
RATE = 44100
if sys.platform.startswith('darwin'):
- CHANNELS = 2
+ CHANNELS = 2
elif sys.platform.startswith('win32'):
- CHANNELS = 1
+ CHANNELS = 1
-MAX_SILENT = 30
+MAX_SILENT = 60
def is_silent(L):
"Returns `True` if below the 'silent' threshold"
@@ -91,7 +91,12 @@
LRtn = array('h')
while 1:
- data = stream.read(CHUNK_SIZE)
+ try:
+ data = stream.read(CHUNK_SIZE)
+ except IOError as ex:
+ if ex[1] != pyaudio.paInputOverflowed:
+ raise
+ data = '\x00' * CHUNK_SIZE
L = unpack('<' + ('h'*(len(data)/2)), data) # little endian, signed short
L = array('h', L)
@@ -100,7 +105,7 @@
if silent and snd_started:
num_silent += 1
- print num_silent
+ #print num_silent
elif not silent and not snd_started:
dispatcher.send( signal='SND_STARTED')
snd_started = True