nagasurendra commited on
Commit
338dd46
·
verified ·
1 Parent(s): 34b8c05

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -7
app.py CHANGED
@@ -26,7 +26,7 @@ html_code = """
26
  <body>
27
  <h1>AI Dining Assistant</h1>
28
  <button class="mic-button" id="mic-button">🎤</button>
29
- <div class="status" id="status">Press the mic button to give your order...</div>
30
  <div class="response" id="response" style="display: none;">Response will appear here...</div>
31
  <script>
32
  const micButton = document.getElementById('mic-button');
@@ -42,8 +42,12 @@ html_code = """
42
  }
43
  });
44
  function startConversation() {
45
- status.textContent = 'Listening... Please give your order.';
46
- startListening();
 
 
 
 
47
  }
48
  function startListening() {
49
  navigator.mediaDevices.getUserMedia({ audio: true }).then(stream => {
@@ -69,10 +73,9 @@ html_code = """
69
  status.textContent = 'Conversation ended. Press the mic button to start again.';
70
  isConversationActive = false;
71
  } else {
72
- status.textContent = 'Waiting for next input...';
73
  setTimeout(() => {
74
- status.textContent = 'Listening... Please give your order.';
75
- startListening();
76
  }, 2000);
77
  }
78
  };
@@ -164,7 +167,7 @@ def process_command(command):
164
  return f"Your final order is: {', '.join(cart)}. Thank you for ordering!"
165
  else:
166
  return "Your cart is empty. Please add items to your cart first."
167
- elif "no" in command or "nothing" in command:
168
  return "Goodbye! Thank you for using AI Dining Assistant."
169
  return "Sorry, I didn't understand your request."
170
 
 
26
  <body>
27
  <h1>AI Dining Assistant</h1>
28
  <button class="mic-button" id="mic-button">🎤</button>
29
+ <div class="status" id="status">Press the mic button to start...</div>
30
  <div class="response" id="response" style="display: none;">Response will appear here...</div>
31
  <script>
32
  const micButton = document.getElementById('mic-button');
 
42
  }
43
  });
44
  function startConversation() {
45
+ const utterance = new SpeechSynthesisUtterance('Please give your order.');
46
+ speechSynthesis.speak(utterance);
47
+ utterance.onend = () => {
48
+ status.textContent = 'Listening...';
49
+ startListening();
50
+ };
51
  }
52
  function startListening() {
53
  navigator.mediaDevices.getUserMedia({ audio: true }).then(stream => {
 
73
  status.textContent = 'Conversation ended. Press the mic button to start again.';
74
  isConversationActive = false;
75
  } else {
76
+ status.textContent = 'Listening...';
77
  setTimeout(() => {
78
+ startConversation();
 
79
  }, 2000);
80
  }
81
  };
 
167
  return f"Your final order is: {', '.join(cart)}. Thank you for ordering!"
168
  else:
169
  return "Your cart is empty. Please add items to your cart first."
170
+ elif "no" in command or "nothing" in command or "goodbye" in command:
171
  return "Goodbye! Thank you for using AI Dining Assistant."
172
  return "Sorry, I didn't understand your request."
173