-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfinalCode.py
More file actions
52 lines (31 loc) · 1.02 KB
/
finalCode.py
File metadata and controls
52 lines (31 loc) · 1.02 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
43
44
45
46
47
48
49
50
51
52
import os
import RPi.GPIO as GPIO
from gtts import gTTS
import vlc
from google.cloud import vision
client = vision.ImageAnnotatorClient()
GPIO.setmode(GPIO.BCM)
GPIO.setup(24, GPIO.IN, pull_up_down=GPIO.PUD_UP)
def capture():
os.system('fswebcam -r 320x240 -S 3 --jpeg 50 --save /home/pi/Desktop/image.jpg')
def final():
capture()
with open('image.jpg', 'rb') as image_file:
content = image_file.read()
image = vision.types.Image(content=content)
response = client.logo_detection(image=image)
response = client.label_detection(image=image)
labels = response.label_annotations
str = " "
for label in labels:
str += label.description + " | "
print(str)
strObj = "Hello. Some of of the relevant results are, ." + str
tts = gTTS(strObj, lang='en')
tts.save("labels.mp3")
player = vlc.MediaPlayer("labels.mp3")
player.play()
while True:
input_state = GPIO.input(24)
if input_state == False:
final()