-
Notifications
You must be signed in to change notification settings - Fork 2
/
player.py
56 lines (42 loc) · 1.27 KB
/
player.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
import time
from multiprocessing import Process
import cv2
import pyttsx3
import numpy as np
video_path = 'sample.mp4'
# text = ""
eng = pyttsx3.init()
def speak(text):
# global text
# Engine created
# time.sleep(2)
print(text)
eng.say(text)
# Runs for small duration of time ohterwise we may not be able to hear
eng.runAndWait()
def play_video():
# global old_caption, new_caption
cap = cv2.VideoCapture(video_path)
print("running")
next_frame = 0
# processes = []
# dict = {"checkpoint_path": checkpoint_path,"image_features_extract_model": image_features_extract_model,
# "top_k": top_k, "tokenizer": tokenizer}
# with open('global_state.pickle', 'wb') as handle:
# pickle.dump(dict, handle, protocol=pickle.HIGHEST_PROTOCOL)
next_frame = 0
while (cap.isOpened()):
next_frame = next_frame + 1
print("player:"+str(next_frame))
if next_frame == 160:
next_frame = 0
#print("running loop")
ret, frame = cap.read()
imS = cv2.resize(frame, (530, 300))
cv2.imshow('frame', imS)
if cv2.waitKey(50) & 0xFF == ord('q'):
break
cap.release()
cv2.destroyAllWindows()
# if __name__ == '__main__':
# speak("i am python")