-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
87 lines (71 loc) · 2.49 KB
/
main.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
from flask import Flask,request,render_template, Response
import camera
from camera import VideoCamera
import Bot
import pyrebase
app = Flask(__name__)
global temp,response
@app.route('/')
def index():
return render_template('index.html')
config = {
"Enter firebase details here"
};
# Initialize Firebase
firebase=pyrebase.initialize_app(config)
db = firebase.database()
@app.route('/temp/', methods=['GET','POST'])
def tdata():
tmp = request.args.get('temp')
temp = tmp
camera.t = tmp
return tmp
def gen(camera):
print("\n\n4:face recog started \n\n")
while True:
frame = camera.get_frame()
yield (b'--frame\r\n' b'Content-Type: image/jpeg\r\n\r\n' + frame + b'\r\n\r\n')
@app.route('/video_feed')
def video_feed():
print("\n\n3:cam on ready\n\n ")
return Response(gen(VideoCamera()),mimetype='multipart/x-mixed-replace; boundary=frame')
@app.route('/audio')
def audio():
print("\n\nSpeech\n\n ")
return render_template('speech.html')
GREETING_INPUTS = ("hello", "hi", "greetings", "sup", "what's up", "hey",)
@app.route("/get")
def chat():
global ans
flag = True
while (flag == True):
user_response = request.args.get('msg')
user_response = user_response.lower()
if user_response not in GREETING_INPUTS and user_response.isalpha() == False:
camera.flat = user_response
if user_response.isalpha() and user_response not in GREETING_INPUTS:
camera.uname = user_response
if (user_response != 'bye'):
if (user_response == 'thanks' or user_response == 'thank you'):
flag = False
response = "You are welcome.."
return response
else:
if (Bot.greeting(user_response) != None):
response = Bot.greeting(user_response)
ans = 1
return response
elif ans == 1:
response = "What is your name? "
ans = 0
return response
else:
response = Bot.response(user_response)
Bot.sent_tokens.remove(user_response)
return response
else:
flag = False
response = "Bye! take care"
return response
if __name__ == '__main__':
app.run(debug=True)