-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathArduino_Blink.py
53 lines (46 loc) · 1.32 KB
/
Arduino_Blink.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
53
import serial
import time
ser = serial.Serial('COM3', 9600)
from sklearn import svm
import speech_recognition as sr
r=sr.Recognizer()
from monkeylearn import MonkeyLearn
ml = MonkeyLearn('31bfede74537bd6c0d8b5d73f01ad4beaa1369d4')
model_id = 'cl_pi3C7JiL'
def led_on_off():
print("How are you feeling today? ")
"""
with sr.Microphone() as source:
audio=r.listen(source)
try:
ip=str(r.recognize_google(audio))
except Exception:
ip='-1'
"""
ip=str(raw_input())
if ip=='-1' or ip.lower()=='bye':
print("Program Exiting")
time.sleep(0.1)
ser.write(b'L')
ser.close()
else:
print(ip)
json=ml.classifiers.classify(model_id, [ip]).body
user_input=json[0]['classifications'][0]['tag_name']
if user_input =='Positive':
print("Positive!\n")
time.sleep(0.1)
ser.write(b'H')
led_on_off()
elif user_input =='Neutral':
print("Neutral!\n")
time.sleep(0.1)
ser.write(b'H')
led_on_off()
elif user_input =='Negative':
print("Negative!\n")
time.sleep(0.1)
ser.write(b'L')
led_on_off()
time.sleep(2)
led_on_off()