-
Notifications
You must be signed in to change notification settings - Fork 0
/
cdrom.py
executable file
·66 lines (46 loc) · 1.18 KB
/
cdrom.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env python3
import os, time
import signal
import sys
from multiprocessing import Process
import requests
import pyttsx3
os.system("clear")
BASE_DIR = os.getenv("SNAP", ".") + "/"
p1 = None
p2 = None
def animate():
frames = []
for i in range(23):
with open(f"{BASE_DIR}frames/frame{i+1}", "r", encoding="utf8") as f:
frames.append(f.readlines())
for repeat in range(1000000):
for frame in frames:
print("".join(frame))
time.sleep(0.4)
os.system("clear")
def sing():
engine = pyttsx3.init()
rate = engine.getProperty("rate")
engine.setProperty("rate", rate - 70)
try:
quote = requests.get(
"https://api.kanye.rest/?format=text"
).content.decode("utf-8")
except Exception:
quote = "The cow is in the house"
engine.say(quote)
engine.runAndWait()
p1.terminate()
def signal_handler(sig, frame):
p1.terminate()
p2.terminate()
sys.exit(0)
signal.signal(signal.SIGINT, signal_handler)
if __name__ == "__main__":
p1 = Process(target=animate)
p1.start()
p2 = Process(target=sing)
p2.start()
p1.join()
p2.join()