Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions PA.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@
import winshell as winshell # pip install winshell
from geopy.geocoders import Nominatim # pip install geopy and pip install geocoder
from geopy import distance
import turtle # pip install turtle
import random # pip install random
import snake_game # user-defined
import turtle
import random
import snake_game
import record

engine = pyttsx3.init()

Expand Down Expand Up @@ -75,7 +76,6 @@ def get_command():


if __name__ == '__main__':

wish_user()
while True:
query = get_command().lower()
Expand Down Expand Up @@ -652,6 +652,10 @@ def send_whtmsg():

except Exception as e:
pass

elif 'screen recording' in query:
fun_talk('Press Q to stop and save recording') #Screen recorder functionality
record.screen_record()

elif 'snake game' in query:
try:
Expand Down
40 changes: 40 additions & 0 deletions record.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import cv2
import psutil
import numpy as np
import os
import pyautogui



def screen_record(): #Screen Recording function

user = psutil.users()[0].name #gets the user name
f_path = "C:\\Users\\" + user + "\\Desktop"
# f_path = input("Enter where u want to save the file") #can also have an option as to where the user wants to save the file
if os.path.exists(f_path):
save_file = os.path.join(f_path,"output.mp4")
else:
save_file ="output.mp4" #saves the file in the corresponding directory

s_size = (1920,1080)
fps = 10.0 #determines how fast the slow the playback speed will be

fcc = cv2.VideoWriter_fourcc(*"mp4v")
out = cv2.VideoWriter(save_file,fcc,fps,(s_size))

while 1:

img = pyautogui.screenshot()
frm = np.array(img)
frm = cv2.cvtColor(frm,cv2.COLOR_BGR2RGB)
cv2.imshow("recorder",frm)
cv2.namedWindow("recorder",cv2.WINDOW_NORMAL)
cv2.resizeWindow("recorder", 800,800)
out.write(frm)

key = cv2.waitKey(1) # q to close the window and stop recording
if key == 113:
break

cv2.destroyAllWindows()
out.release()