mirror of
https://github.com/brmlab/kryton.git
synced 2025-06-07 09:44:01 +02:00
init
This commit is contained in:
commit
9774f103de
4 changed files with 49 additions and 0 deletions
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
*.avi
|
||||
*.mp4
|
||||
*.flv
|
1
README
Normal file
1
README
Normal file
|
@ -0,0 +1 @@
|
|||
Lab sentient companion
|
43
detector.py
Executable file
43
detector.py
Executable 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
2
run.sh
Executable file
|
@ -0,0 +1,2 @@
|
|||
#!/bin/bash
|
||||
./detector.py | mplayer -fs -vo directfb -slave $1 -loop 0
|
Loading…
Add table
Add a link
Reference in a new issue