Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -17,20 +17,23 @@ 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 |
-
# Menu Data (
|
| 21 |
def load_menu():
|
| 22 |
menu = {
|
| 23 |
-
"
|
| 24 |
-
{"name": "
|
| 25 |
-
{"name": "
|
|
|
|
| 26 |
],
|
| 27 |
-
"
|
| 28 |
-
{"name": "Butter
|
| 29 |
-
{"name": "
|
|
|
|
| 30 |
],
|
| 31 |
-
"
|
| 32 |
-
{"name": "Chicken
|
| 33 |
-
{"name": "
|
|
|
|
| 34 |
]
|
| 35 |
}
|
| 36 |
return menu
|
|
@@ -38,18 +41,18 @@ def load_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 '
|
| 46 |
-
return "Our
|
| 47 |
|
| 48 |
-
elif '
|
| 49 |
-
return "Our
|
| 50 |
|
| 51 |
-
elif '
|
| 52 |
-
return "Our
|
| 53 |
|
| 54 |
return "I'm sorry, I didn't understand that command."
|
| 55 |
|
|
@@ -90,7 +93,7 @@ def interact_with_assistant(user_input, speaker_audio, language):
|
|
| 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([ '
|
| 94 |
],
|
| 95 |
outputs=gr.Audio(type="filepath", label="Generated audio file"),
|
| 96 |
title="Voice Assistant - Menu and Voice Cloning")
|
|
|
|
| 17 |
# Init TTS
|
| 18 |
tts = TTS("tts_models/multilingual/multi-dataset/xtts_v2").to(device)
|
| 19 |
|
| 20 |
+
# Updated Menu Data (Including Drinks, Vegetarian, Non-Vegetarian)
|
| 21 |
def load_menu():
|
| 22 |
menu = {
|
| 23 |
+
"Drinks": [
|
| 24 |
+
{"name": "Coca-Cola", "price": 1.50, "description": "Refreshing carbonated soft drink"},
|
| 25 |
+
{"name": "Lemonade", "price": 1.20, "description": "Freshly made lemon drink with a sweet twist"},
|
| 26 |
+
{"name": "Mango Lassi", "price": 2.00, "description": "Smooth yogurt drink with mango flavor"}
|
| 27 |
],
|
| 28 |
+
"Vegetarian": [
|
| 29 |
+
{"name": "Paneer Butter Masala", "price": 6.99, "description": "Cottage cheese in a creamy, spiced gravy"},
|
| 30 |
+
{"name": "Chole Bhature", "price": 5.50, "description": "Spicy chickpeas served with deep-fried bread"},
|
| 31 |
+
{"name": "Aloo Gobi", "price": 5.00, "description": "Potatoes and cauliflower cooked with spices"}
|
| 32 |
],
|
| 33 |
+
"Non-Vegetarian": [
|
| 34 |
+
{"name": "Butter Chicken", "price": 7.99, "description": "Grilled chicken cooked in a rich, creamy sauce"},
|
| 35 |
+
{"name": "Chicken Tikka", "price": 6.50, "description": "Marinated chicken chunks grilled to perfection"},
|
| 36 |
+
{"name": "Lamb Rogan Josh", "price": 8.99, "description": "Tender lamb cooked in aromatic spices and gravy"}
|
| 37 |
]
|
| 38 |
}
|
| 39 |
return 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 'drinks' in command.lower():
|
| 49 |
+
return "Our drinks: " + ", ".join([item['name'] for item in menu["Drinks"]])
|
| 50 |
|
| 51 |
+
elif 'vegetarian' in command.lower():
|
| 52 |
+
return "Our vegetarian dishes: " + ", ".join([item['name'] for item in menu["Vegetarian"]])
|
| 53 |
|
| 54 |
+
elif 'non-vegetarian' in command.lower():
|
| 55 |
+
return "Our non-vegetarian dishes: " + ", ".join([item['name'] for item in menu["Non-Vegetarian"]])
|
| 56 |
|
| 57 |
return "I'm sorry, I didn't understand that command."
|
| 58 |
|
|
|
|
| 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="Language"),
|
| 97 |
],
|
| 98 |
outputs=gr.Audio(type="filepath", label="Generated audio file"),
|
| 99 |
title="Voice Assistant - Menu and Voice Cloning")
|