Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -17,23 +17,20 @@ device = "cuda" if torch.cuda.is_available() else "cpu"
|
|
| 17 |
# Init TTS
|
| 18 |
tts = TTS("tts_models/multilingual/multi-dataset/xtts_v2").to(device)
|
| 19 |
|
| 20 |
-
#
|
| 21 |
def load_menu():
|
| 22 |
menu = {
|
| 23 |
-
"
|
| 24 |
-
{"name": "
|
| 25 |
-
{"name": "
|
| 26 |
-
{"name": "Mango Lassi", "price": 2.00, "description": "Smooth yogurt drink with mango flavor"}
|
| 27 |
],
|
| 28 |
-
"
|
| 29 |
-
{"name": "
|
| 30 |
-
{"name": "
|
| 31 |
-
{"name": "Aloo Gobi", "price": 5.00, "description": "Potatoes and cauliflower cooked with spices"}
|
| 32 |
],
|
| 33 |
-
"
|
| 34 |
-
{"name": "
|
| 35 |
-
{"name": "
|
| 36 |
-
{"name": "Lamb Rogan Josh", "price": 8.99, "description": "Tender lamb cooked in aromatic spices and gravy"}
|
| 37 |
]
|
| 38 |
}
|
| 39 |
return menu
|
|
@@ -41,18 +38,18 @@ def load_menu():
|
|
| 41 |
# Function to process commands and get menu details
|
| 42 |
def process_command(command):
|
| 43 |
menu = load_menu()
|
| 44 |
-
|
| 45 |
if 'menu' in command.lower():
|
| 46 |
return "Here's our menu: \n" + "\n".join([f"{category}: {', '.join([item['name'] for item in items])}" for category, items in menu.items()])
|
| 47 |
|
| 48 |
-
elif '
|
| 49 |
-
return "Our
|
| 50 |
|
| 51 |
-
elif '
|
| 52 |
-
return "Our
|
| 53 |
|
| 54 |
-
elif '
|
| 55 |
-
return "Our
|
| 56 |
|
| 57 |
return "I'm sorry, I didn't understand that command."
|
| 58 |
|
|
@@ -93,9 +90,9 @@ def interact_with_assistant(user_input, speaker_audio, language):
|
|
| 93 |
iface = gr.Interface(fn=interact_with_assistant,
|
| 94 |
inputs=[gr.Textbox(lines=2, placeholder="Enter the text...", label="Text"),
|
| 95 |
gr.Audio(type="filepath", label="Upload audio file"),
|
| 96 |
-
gr.Radio(['ru', 'en', 'zh-cn', 'ja', 'de', 'fr', 'it', 'pt', 'pl', 'tr', 'ko', 'nl', 'cs', 'ar', 'es', 'hu'], label="
|
| 97 |
],
|
| 98 |
outputs=gr.Audio(type="filepath", label="Generated audio file"),
|
| 99 |
title="Voice Assistant - Menu and Voice Cloning")
|
| 100 |
|
| 101 |
-
iface.launch()
|
|
|
|
| 17 |
# Init TTS
|
| 18 |
tts = TTS("tts_models/multilingual/multi-dataset/xtts_v2").to(device)
|
| 19 |
|
| 20 |
+
# Menu Data (You can modify this as per your actual menu)
|
| 21 |
def load_menu():
|
| 22 |
menu = {
|
| 23 |
+
"Breads": [
|
| 24 |
+
{"name": "Roti", "price": 1.50, "description": "Indian flatbread"},
|
| 25 |
+
{"name": "Naan", "price": 2.00, "description": "Soft leavened flatbread"}
|
|
|
|
| 26 |
],
|
| 27 |
+
"Curries": [
|
| 28 |
+
{"name": "Butter Chicken", "price": 7.99, "description": "Creamy and rich chicken curry"},
|
| 29 |
+
{"name": "Paneer Tikka Masala", "price": 6.99, "description": "Cottage cheese in a spiced gravy"}
|
|
|
|
| 30 |
],
|
| 31 |
+
"Biryanis": [
|
| 32 |
+
{"name": "Chicken Biryani", "price": 8.99, "description": "Fragrant rice with spiced chicken"},
|
| 33 |
+
{"name": "Vegetable Biryani", "price": 7.50, "description": "Fragrant rice with mixed vegetables"}
|
|
|
|
| 34 |
]
|
| 35 |
}
|
| 36 |
return menu
|
|
|
|
| 38 |
# Function to process commands and get menu details
|
| 39 |
def process_command(command):
|
| 40 |
menu = load_menu()
|
| 41 |
+
|
| 42 |
if 'menu' in command.lower():
|
| 43 |
return "Here's our menu: \n" + "\n".join([f"{category}: {', '.join([item['name'] for item in items])}" for category, items in menu.items()])
|
| 44 |
|
| 45 |
+
elif 'breads' in command.lower():
|
| 46 |
+
return "Our breads: " + ", ".join([item['name'] for item in menu["Breads"]])
|
| 47 |
|
| 48 |
+
elif 'curries' in command.lower():
|
| 49 |
+
return "Our curries: " + ", ".join([item['name'] for item in menu["Curries"]])
|
| 50 |
|
| 51 |
+
elif 'biryani' in command.lower():
|
| 52 |
+
return "Our biryanis: " + ", ".join([item['name'] for item in menu["Biryanis"]])
|
| 53 |
|
| 54 |
return "I'm sorry, I didn't understand that command."
|
| 55 |
|
|
|
|
| 90 |
iface = gr.Interface(fn=interact_with_assistant,
|
| 91 |
inputs=[gr.Textbox(lines=2, placeholder="Enter the text...", label="Text"),
|
| 92 |
gr.Audio(type="filepath", label="Upload audio file"),
|
| 93 |
+
gr.Radio(['ru', 'en', 'zh-cn', 'ja', 'de', 'fr', 'it', 'pt', 'pl', 'tr', 'ko', 'nl', 'cs', 'ar', 'es', 'hu'], label="language"),
|
| 94 |
],
|
| 95 |
outputs=gr.Audio(type="filepath", label="Generated audio file"),
|
| 96 |
title="Voice Assistant - Menu and Voice Cloning")
|
| 97 |
|
| 98 |
+
iface.launch()
|