-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcoding.py
More file actions
40 lines (30 loc) · 937 Bytes
/
coding.py
File metadata and controls
40 lines (30 loc) · 937 Bytes
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
from video import video
from speechRecognition import voice
import threading
from time import sleep
# Global variables
face_id = "empty"
stop_flag = False # Flag to signal threads to stop
# Lock to synchronize access to the global variable
lock = threading.Lock()
def main():
global stop_flag
# Create threads
thread1 = threading.Thread(target=video)
thread2 = threading.Thread(target=voice)
# Start both threads
thread1.start()
thread2.start()
# Wait for user to interrupt with Ctrl + C
try:
while True:
sleep(1) # Keep the main thread alive
except KeyboardInterrupt:
stop_flag = True # Set stop_flag to true to stop the threads
print("\nProgram interrupted by user with Ctrl + C")
# Wait for both threads to finish
thread1.join()
thread2.join()
print("Both threads have finished execution.")
if __name__ == "__main__":
main()