-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.py
49 lines (34 loc) · 845 Bytes
/
server.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import pyaudio
import collections
import threading
'''
ZombieComm radio server
'''
sound_frames = collections.deque()
def record():
global sound_frames
CHUNK = 1024
FORMAT = pyaudio.paInt16
CHANNELS = 2
RATE = 10000
p = pyaudio.PyAudio()
stream = p.open(format=FORMAT,
channels=CHANNELS,
rate=RATE,
input=True,
frames_per_buffer=CHUNK)
while True:
data = stream.read(CHUNK)
sound_frames.append(data)
if __name__ == '__main__':
'''
main method simply prints recorded data right now
'''
t = threading.Thread(target=record)
t.start()
while True:
try:
if len(sound_frames) > 0:
print (sound_frames.popleft())
except:
pass