dschandra commited on
Commit
8acfe6f
·
verified ·
1 Parent(s): 283764f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -3
app.py CHANGED
@@ -116,8 +116,22 @@ html_code = """
116
  response.textContent = data.response;
117
  response.style.display = 'block';
118
 
119
- const utterance = new SpeechSynthesisUtterance(data.response);
120
- speechSynthesis.speak(utterance);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
121
 
122
  if (data.response.includes("Goodbye")) {
123
  status.textContent = 'Conversation ended. Press the mic button to start again.';
@@ -207,7 +221,12 @@ def process_command(command):
207
  """Process the user's voice command and return a response."""
208
  command = command.lower()
209
  if "menu" in command:
210
- return "Our menu includes paneer butter masala, fried rice, and cold coffee. What would you like to order?"
 
 
 
 
 
211
  elif "order" in command:
212
  return "Your order has been placed. Would you like anything else?"
213
  elif "no" in command or "nothing" in command:
 
116
  response.textContent = data.response;
117
  response.style.display = 'block';
118
 
119
+ try {
120
+ const utterance = new SpeechSynthesisUtterance(data.response);
121
+ speechSynthesis.speak(utterance);
122
+
123
+ utterance.onend = () => {
124
+ console.log("Speech synthesis completed.");
125
+ };
126
+
127
+ utterance.onerror = (e) => {
128
+ console.error("Speech synthesis error:", e.error);
129
+ status.textContent = 'Error with speech output.';
130
+ };
131
+ } catch (speechError) {
132
+ console.error("Speech synthesis not supported or failed:", speechError);
133
+ response.textContent = "Speech output unavailable. Please check your browser.";
134
+ }
135
 
136
  if (data.response.includes("Goodbye")) {
137
  status.textContent = 'Conversation ended. Press the mic button to start again.';
 
221
  """Process the user's voice command and return a response."""
222
  command = command.lower()
223
  if "menu" in command:
224
+ return (
225
+ "Here is our menu: "
226
+ "South Indian dishes include Idli, Dosa, Vada, Pongal, Biryani, and Sambar Rice. "
227
+ "North Indian dishes include Butter Chicken, Paneer Butter Masala, Naan, Dal Makhani, Chole Bhature, and Rajma Chawal. "
228
+ "What would you like to order?"
229
+ )
230
  elif "order" in command:
231
  return "Your order has been placed. Would you like anything else?"
232
  elif "no" in command or "nothing" in command: