forked from armadaplatform/armada
-
Notifications
You must be signed in to change notification settings - Fork 0
/
command_poker.py
44 lines (35 loc) · 1.1 KB
/
command_poker.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
import random
import sys
import wave
try:
import pyaudio
except ImportError:
audio = False
else:
audio = True
CHUNK = 1024
def command_poker(args):
if audio:
try:
so_sick = '/opt/armada/armada_command/utils/so_sick/{}.wav'.format(random.randint(1, 11))
wf = wave.open(so_sick, 'rb')
p = pyaudio.PyAudio()
stream = p.open(format=p.get_format_from_width(wf.getsampwidth()),
channels=wf.getnchannels(),
rate=wf.getframerate(),
output=True)
data = wf.readframes(CHUNK)
while data != '':
stream.write(data)
data = wf.readframes(CHUNK)
stream.stop_stream()
stream.close()
p.terminate()
except Exception:
pass
with open('/opt/armada/armada_command/utils/so_sick/poker', 'rb') as im:
for line in im:
sys.stdout.write(line)
if not audio:
print("So sick!")
print(" Want more sickness? Try getting python-pyaudio.")