Spaces:
Runtime error
Runtime error
Commit
·
14364bf
1
Parent(s):
4592ae2
Update app.py
Browse files
app.py
CHANGED
@@ -9,7 +9,7 @@ restaurants = {
|
|
9 |
"Vegetable Pizza": 15.99,
|
10 |
"Caesar Salad": 8.99,
|
11 |
"Garlic Knots": 5.99,
|
12 |
-
"
|
13 |
"Chocolate Chip Cookie": 2.99
|
14 |
},
|
15 |
"Burger King": {
|
@@ -30,22 +30,22 @@ restaurants = {
|
|
30 |
"Baja Blast Freeze": 2.49,
|
31 |
"Cinnamon Twists": 1.99
|
32 |
},
|
33 |
-
"McDonald's": {
|
34 |
-
"Big Mac
|
35 |
-
"10-Piece Chicken
|
36 |
-
"Filet
|
37 |
-
"
|
38 |
"French Fries": 1.89,
|
39 |
"Soft Drink": 1.00,
|
40 |
"Apple Pie": 0.99
|
41 |
},
|
42 |
-
"Chipotle": {
|
43 |
"Burrito Bowl": 7.99,
|
44 |
"Steak Quesadilla": 4.99,
|
45 |
"Crispy Tacos": 3.99,
|
46 |
"Barbacoa Salad": 8.99,
|
47 |
-
"Chips
|
48 |
-
"
|
49 |
"Chocolate Brownie": 2.25
|
50 |
}
|
51 |
}
|
@@ -106,18 +106,18 @@ def main(audio):
|
|
106 |
command = recognize_speech(audio)
|
107 |
print(f"You said: {command}")
|
108 |
txt_command ="extract the food related command keyword from the sentence :\n\n"+command
|
109 |
-
food_command = nlp(txt_command).strip()
|
110 |
|
111 |
restaurant_name = ''
|
112 |
txt_extract = "extract the restaurants name keyword from the sentence :\n\n"+command
|
113 |
-
restaurant_name = ((nlp(txt_extract)).strip()).title()
|
114 |
found_rest = False
|
115 |
if(restaurant_name in restaurants.keys()):
|
116 |
found_rest = True
|
117 |
|
118 |
item_name = ''
|
119 |
txt_extract = "extract the food item from the sentence :\n\n"+command
|
120 |
-
item_name = ((nlp(txt_extract)).strip()).title()
|
121 |
found_item = False
|
122 |
if(restaurant_name in restaurants.keys()):
|
123 |
found_item = True
|
@@ -162,6 +162,7 @@ def main(audio):
|
|
162 |
|
163 |
|
164 |
elif food_command in ['menu' , 'menus' , 'catalogue' , 'items' , 'something']:
|
|
|
165 |
for restaurant in restaurants:
|
166 |
if restaurant in command:
|
167 |
menu_items = get_menu_items(restaurant)
|
@@ -169,6 +170,8 @@ def main(audio):
|
|
169 |
break
|
170 |
else:
|
171 |
response= "Sorry, I didn't catch the restaurant name. Could you please repeat that?"
|
|
|
|
|
172 |
elif identify_food_command(command) == 'food':
|
173 |
response=chatbot("Respond a person properly who has come to your restaurant asking food")
|
174 |
else:
|
|
|
9 |
"Vegetable Pizza": 15.99,
|
10 |
"Caesar Salad": 8.99,
|
11 |
"Garlic Knots": 5.99,
|
12 |
+
"Diet Coke": 2.99,
|
13 |
"Chocolate Chip Cookie": 2.99
|
14 |
},
|
15 |
"Burger King": {
|
|
|
30 |
"Baja Blast Freeze": 2.49,
|
31 |
"Cinnamon Twists": 1.99
|
32 |
},
|
33 |
+
"Mr McDonald's": {
|
34 |
+
"Big Mac-Meal": 6.49,
|
35 |
+
"10-Piece Chicken-McNuggets": 4.29,
|
36 |
+
"Filet Fish": 3.79,
|
37 |
+
"Cheessy Quarte-Pounder": 5.19,
|
38 |
"French Fries": 1.89,
|
39 |
"Soft Drink": 1.00,
|
40 |
"Apple Pie": 0.99
|
41 |
},
|
42 |
+
"Chipotle House": {
|
43 |
"Burrito Bowl": 7.99,
|
44 |
"Steak Quesadilla": 4.99,
|
45 |
"Crispy Tacos": 3.99,
|
46 |
"Barbacoa Salad": 8.99,
|
47 |
+
"Chips Guac": 3.99,
|
48 |
+
"Soft Drinks": 2.29,
|
49 |
"Chocolate Brownie": 2.25
|
50 |
}
|
51 |
}
|
|
|
106 |
command = recognize_speech(audio)
|
107 |
print(f"You said: {command}")
|
108 |
txt_command ="extract the food related command keyword from the sentence :\n\n"+command
|
109 |
+
food_command = (" ".join(nlp(txt_command).strip().split()[-1:])).lower()
|
110 |
|
111 |
restaurant_name = ''
|
112 |
txt_extract = "extract the restaurants name keyword from the sentence :\n\n"+command
|
113 |
+
restaurant_name = " ".join(((nlp(txt_extract)).strip()).title().split()[-2:]))
|
114 |
found_rest = False
|
115 |
if(restaurant_name in restaurants.keys()):
|
116 |
found_rest = True
|
117 |
|
118 |
item_name = ''
|
119 |
txt_extract = "extract the food item from the sentence :\n\n"+command
|
120 |
+
item_name = " ".join( ((nlp(txt_extract)).strip()).title().strip(".,;:").split()[-2:])
|
121 |
found_item = False
|
122 |
if(restaurant_name in restaurants.keys()):
|
123 |
found_item = True
|
|
|
162 |
|
163 |
|
164 |
elif food_command in ['menu' , 'menus' , 'catalogue' , 'items' , 'something']:
|
165 |
+
if found_rest:
|
166 |
for restaurant in restaurants:
|
167 |
if restaurant in command:
|
168 |
menu_items = get_menu_items(restaurant)
|
|
|
170 |
break
|
171 |
else:
|
172 |
response= "Sorry, I didn't catch the restaurant name. Could you please repeat that?"
|
173 |
+
else:
|
174 |
+
response = chatbot(command)
|
175 |
elif identify_food_command(command) == 'food':
|
176 |
response=chatbot("Respond a person properly who has come to your restaurant asking food")
|
177 |
else:
|