This commit is contained in:
Pavol Rusnak 2013-06-03 13:07:59 +02:00
commit 9774f103de
4 changed files with 49 additions and 0 deletions

3
.gitignore vendored Normal file
View file

@ -0,0 +1,3 @@
*.avi
*.mp4
*.flv

1
README Normal file
View file

@ -0,0 +1 @@
Lab sentient companion

43
detector.py Executable file
View file

@ -0,0 +1,43 @@
#!/usr/bin/python
import pyaudio
import array
import time
import sys
CHUNK = 1024
p = pyaudio.PyAudio()
stream = p.open(format = pyaudio.paInt16,
channels = 1,
rate = 48000,
input = True,
frames_per_buffer = CHUNK,
input_device_index = 0)
last = time.time()
print 'pause'
sys.stdout.flush()
while True:
try:
data = stream.read(CHUNK)
except:
stream.stop_stream()
stream.start_stream()
continue
data = array.array("h", data)
if last < time.time() - 1:
if max(data) < -32000:
last = time.time()
print 'pause'
sys.stdout.flush()
if min(data) > 32000:
last = time.time()
print 'pause'
sys.stdout.flush()
stream.stop_stream()
stream.close()
p.terminate()

2
run.sh Executable file
View file

@ -0,0 +1,2 @@
#!/bin/bash
./detector.py | mplayer -fs -vo directfb -slave $1 -loop 0