Spaces:
Build error
Build error
DSatishchandra
commited on
Commit
•
9eea94c
1
Parent(s):
6f215e1
Update app.py
Browse files
app.py
CHANGED
@@ -21,8 +21,8 @@ def speak(text):
|
|
21 |
# Do not try to play the audio, just save it
|
22 |
# os.system("mpg321 output.mp3") # Removed, as it is not supported in Hugging Face
|
23 |
|
24 |
-
# Function to process the order
|
25 |
-
def process_order(order):
|
26 |
response = "You have ordered the following: "
|
27 |
order = order.lower()
|
28 |
|
@@ -35,18 +35,25 @@ def process_order(order):
|
|
35 |
|
36 |
if ordered_items:
|
37 |
response += ', '.join(ordered_items) + ". Is that correct?"
|
38 |
-
|
39 |
-
|
|
|
|
|
|
|
|
|
40 |
else:
|
41 |
speak("Sorry, I couldn't find any items matching your order. Can you try again?")
|
42 |
return "Sorry, I couldn't find any items matching your order. Can you try again?"
|
43 |
|
44 |
# Create Gradio interface
|
45 |
-
def start_assistant(order):
|
46 |
-
return process_order(order)
|
47 |
|
48 |
# Gradio interface setup
|
49 |
-
iface = gr.Interface(fn=start_assistant, inputs=
|
|
|
|
|
|
|
50 |
|
51 |
# Launch the interface
|
52 |
iface.launch()
|
|
|
21 |
# Do not try to play the audio, just save it
|
22 |
# os.system("mpg321 output.mp3") # Removed, as it is not supported in Hugging Face
|
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 |
|
|
|
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. Can you try again?"
|
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()
|