Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -3,7 +3,6 @@ from time import time
|
|
3 |
import pickle as pk
|
4 |
import mediapipe as mp
|
5 |
import pandas as pd
|
6 |
-
import pyttsx4
|
7 |
import multiprocessing as mtp
|
8 |
|
9 |
from recommendations import check_pose_angle
|
@@ -65,20 +64,6 @@ def init_dicts():
|
|
65 |
return cols, landmarks_points_array
|
66 |
|
67 |
|
68 |
-
engine = pyttsx4.init()
|
69 |
-
|
70 |
-
|
71 |
-
def tts(tts_q):
|
72 |
-
while True:
|
73 |
-
objects = tts_q.get()
|
74 |
-
if objects is None:
|
75 |
-
break
|
76 |
-
message = objects[0]
|
77 |
-
engine.say(message)
|
78 |
-
engine.runAndWait()
|
79 |
-
tts_q.task_done()
|
80 |
-
|
81 |
-
|
82 |
def cv2_put_text(image, message):
|
83 |
cv2.putText(
|
84 |
image,
|
@@ -92,13 +77,9 @@ def cv2_put_text(image, message):
|
|
92 |
)
|
93 |
|
94 |
|
95 |
-
def
|
96 |
cv2.destroyAllWindows()
|
97 |
cam.release()
|
98 |
-
tts_q.put(None)
|
99 |
-
tts_q.close()
|
100 |
-
tts_q.join_thread()
|
101 |
-
tts_proc.join()
|
102 |
|
103 |
|
104 |
if __name__ == "__main__":
|
@@ -109,11 +90,6 @@ if __name__ == "__main__":
|
|
109 |
mp_drawing = mp.solutions.drawing_utils
|
110 |
mp_pose = mp.solutions.pose
|
111 |
|
112 |
-
tts_q = mtp.JoinableQueue()
|
113 |
-
|
114 |
-
tts_proc = mtp.Process(target=tts, args=(tts_q, ))
|
115 |
-
tts_proc.start()
|
116 |
-
|
117 |
tts_last_exec = time() + 5
|
118 |
|
119 |
while True:
|
@@ -127,7 +103,7 @@ if __name__ == "__main__":
|
|
127 |
|
128 |
key = cv2.waitKey(1)
|
129 |
if key == ord("q"):
|
130 |
-
|
131 |
break
|
132 |
|
133 |
if result:
|
@@ -158,9 +134,11 @@ if __name__ == "__main__":
|
|
158 |
prediction[0], angles, angles_df)
|
159 |
|
160 |
if time() > tts_last_exec:
|
161 |
-
|
|
|
|
|
162 |
suggestions[0]
|
163 |
-
|
164 |
tts_last_exec = time() + 5
|
165 |
|
166 |
else:
|
|
|
3 |
import pickle as pk
|
4 |
import mediapipe as mp
|
5 |
import pandas as pd
|
|
|
6 |
import multiprocessing as mtp
|
7 |
|
8 |
from recommendations import check_pose_angle
|
|
|
64 |
return cols, landmarks_points_array
|
65 |
|
66 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
def cv2_put_text(image, message):
|
68 |
cv2.putText(
|
69 |
image,
|
|
|
77 |
)
|
78 |
|
79 |
|
80 |
+
def destroy(cam):
|
81 |
cv2.destroyAllWindows()
|
82 |
cam.release()
|
|
|
|
|
|
|
|
|
83 |
|
84 |
|
85 |
if __name__ == "__main__":
|
|
|
90 |
mp_drawing = mp.solutions.drawing_utils
|
91 |
mp_pose = mp.solutions.pose
|
92 |
|
|
|
|
|
|
|
|
|
|
|
93 |
tts_last_exec = time() + 5
|
94 |
|
95 |
while True:
|
|
|
103 |
|
104 |
key = cv2.waitKey(1)
|
105 |
if key == ord("q"):
|
106 |
+
destroy(cam)
|
107 |
break
|
108 |
|
109 |
if result:
|
|
|
134 |
prediction[0], angles, angles_df)
|
135 |
|
136 |
if time() > tts_last_exec:
|
137 |
+
# Display suggestions on screen
|
138 |
+
cv2_put_text(
|
139 |
+
flipped,
|
140 |
suggestions[0]
|
141 |
+
)
|
142 |
tts_last_exec = time() + 5
|
143 |
|
144 |
else:
|