Spaces:
Build error
Build error
DSatishchandra
commited on
Commit
•
3d3c5c6
1
Parent(s):
c412ea1
Update app.py
Browse files
app.py
CHANGED
@@ -1,59 +1,23 @@
|
|
1 |
import gradio as gr
|
2 |
-
|
3 |
-
import
|
4 |
-
|
5 |
-
#
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
# Function to process the order and handle confirmation
|
25 |
-
def process_order(order, confirmation):
|
26 |
-
response = "You have ordered the following: "
|
27 |
-
order = order.lower()
|
28 |
-
|
29 |
-
# Check for matching menu items
|
30 |
-
ordered_items = []
|
31 |
-
for category, items in menu.items():
|
32 |
-
for item in items:
|
33 |
-
if item.lower() in order:
|
34 |
-
ordered_items.append(item)
|
35 |
-
|
36 |
-
if ordered_items:
|
37 |
-
response += ', '.join(ordered_items) + ". Is that correct?"
|
38 |
-
if confirmation.lower() == "yes":
|
39 |
-
speak("Thank you for your order. It will be ready shortly!")
|
40 |
-
return "Order confirmed. " + response
|
41 |
-
else:
|
42 |
-
speak("Please tell me again what you'd like to order.")
|
43 |
-
return "Order not confirmed. Please try again."
|
44 |
-
else:
|
45 |
-
speak("Sorry, I couldn't find any items matching your order. Can you try again?")
|
46 |
-
return "Sorry, I couldn't find any items matching your order."
|
47 |
-
|
48 |
-
# Create Gradio interface
|
49 |
-
def start_assistant(order, confirmation):
|
50 |
-
return process_order(order, confirmation)
|
51 |
-
|
52 |
-
# Gradio interface setup
|
53 |
-
iface = gr.Interface(fn=start_assistant, inputs=["text", "text"], outputs="text",
|
54 |
-
live=True,
|
55 |
-
title="Voice Food Ordering Assistant",
|
56 |
-
description="Type your food order and confirm your order.")
|
57 |
-
|
58 |
-
# Launch the interface
|
59 |
-
iface.launch()
|
|
|
1 |
import gradio as gr
|
2 |
+
import name
|
3 |
+
import asyncio
|
4 |
+
|
5 |
+
# Gradio interface function
|
6 |
+
def food_order_interface():
|
7 |
+
return name.food_order_assistant()
|
8 |
+
|
9 |
+
# Create Gradio application
|
10 |
+
async def create_demo():
|
11 |
+
demo = gr.Interface(fn=food_order_interface,
|
12 |
+
inputs=[gr.Textbox(label="Order Food", lines=2),
|
13 |
+
gr.Dropdown(choices=["Starters", "Main Course", "Desserts"], label="Food Type")],
|
14 |
+
outputs=[gr.Audio(label="Order Confirmation Audio"),
|
15 |
+
gr.Textbox(label="Confirmed Order Details", interactive=False)],
|
16 |
+
title="AI Restaurant Voice Ordering",
|
17 |
+
description="Order food easily with the AI assistant's voice ordering system.")
|
18 |
+
return demo
|
19 |
+
|
20 |
+
# Run the application
|
21 |
+
if __name__ == "__main__":
|
22 |
+
demo = asyncio.run(create_demo())
|
23 |
+
demo.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|