-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
42 lines (29 loc) · 1.04 KB
/
test.py
File metadata and controls
42 lines (29 loc) · 1.04 KB
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
import pyautogui
import cv2
import sounddevice as sd
from scipy.io.wavfile import write
import sounddevice as sd
import soundfile as sf
import wavio as wv
def screenshot(filename):
filen = pyautogui.screenshot()
filen.save(f'{filename}.png')
def takpic(filename):
cap = cv2.VideoCapture(0) # video capture source camera (Here webcam of laptop)
ret,frame = cap.read() # return a single frame in variable `frame`
while(True):
cv2.imshow('img1',frame) #display the captured image
if cv2.waitKey(1) & 0xFF == ord('y'): #save on pressing 'y'
cv2.imwrite(f'{filename}.png',frame)
cv2.destroyAllWindows()
break
cap.release()
def recordaudio(filename,duration):
samplerate = 44100 # Hertz
seconds = duration
filename = f'{filename}.wav'
myrecording = sd.rec(int(seconds * samplerate), samplerate=samplerate,
channels=1)
sd.wait()
sf.write(filename, myrecording, samplerate)
recordaudio("testaudi",6)