lokesh341 commited on
Commit
450cc5e
·
verified ·
1 Parent(s): d6d83af

Update templates/index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +32 -54
templates/index.html CHANGED
@@ -8,7 +8,7 @@
8
  <style>
9
  body {
10
  font-family: 'Roboto', sans-serif;
11
- background: linear-gradient(135deg, #f4c542, #ff8f6a); /* Light gradient background */
12
  margin: 0;
13
  display: flex;
14
  justify-content: center;
@@ -17,7 +17,7 @@
17
  text-align: center;
18
  }
19
  .container {
20
- background:lightblue;
21
  padding: 40px 50px;
22
  border-radius: 10px;
23
  width: 400px;
@@ -26,7 +26,7 @@
26
  h1 {
27
  font-size: 30px;
28
  font-weight: bold;
29
- color: #ff6a00; /* Bright orange for title */
30
  }
31
  label {
32
  font-size: 18px;
@@ -59,29 +59,24 @@
59
  <div class="container">
60
  <h1>Welcome to Biryani Hub</h1>
61
 
62
- <!-- Name Input Field -->
63
  <label for="name">Your Name</label>
64
  <input type="text" id="name" placeholder="Your name will appear here..." readonly>
65
 
66
- <!-- Email Input Field -->
67
  <label for="email">Your Email</label>
68
  <input type="text" id="email" placeholder="Your email will appear here..." readonly>
69
 
70
- <!-- Info Message for Listening -->
71
  <p class="info" id="infoMessage">Listening will start automatically...</p>
72
-
73
- <!-- Status Message -->
74
  <p class="status" id="status">Initializing...</p>
75
  </div>
76
 
77
  <script>
78
  let recognition;
79
- let isListening = false;
80
  let isNameCaptured = false;
 
81
 
82
  if ('webkitSpeechRecognition' in window) {
83
  recognition = new webkitSpeechRecognition();
84
- recognition.continuous = false; // Stop after capturing each input
85
  recognition.interimResults = false;
86
  recognition.lang = 'en-US';
87
  } else {
@@ -90,63 +85,46 @@
90
 
91
  function speak(text, callback) {
92
  const speech = new SpeechSynthesisUtterance(text);
93
- speech.onend = callback; // Once the speech ends, call the next function
94
  window.speechSynthesis.speak(speech);
95
  }
96
 
97
- function startListeningForName() {
98
- const status = document.getElementById('status');
99
- const nameInput = document.getElementById('name');
100
-
101
- status.textContent = "Listening for your name...";
102
- recognition.start();
103
-
104
- recognition.onresult = function(event) {
105
- const transcript = event.results[0][0].transcript.trim();
106
- nameInput.value = transcript;
107
- recognition.stop();
108
-
109
- // Now, prompt for email
110
- speak("Tell me your email", startListeningForEmail);
111
- };
112
  }
113
 
114
- function startListeningForEmail() {
115
  const status = document.getElementById('status');
 
116
  const emailInput = document.getElementById('email');
117
-
118
- status.textContent = "Listening for your email...";
119
  recognition.start();
120
-
121
  recognition.onresult = function(event) {
122
- let transcript = event.results[0][0].transcript.trim();
123
-
124
- // If name is captured, we now capture email
125
- if (isNameCaptured && !isEmailCaptured) {
126
- // Correct email input format by removing spaces and handling @ properly
127
- const cleanedEmail = transcript.replace(/\s/g, '').replace('@', ' @ '); // Keep space around '@' properly
128
-
129
- // Remove unwanted spaces from the email input
130
- emailInput.value = transcript;
131
-
132
- recognition.stop();
133
-
134
- status.textContent = "Registration complete .";
135
- speak("Registration complete Go To The Next step and take the order what you want.");
136
-
137
- // Refresh after 20 seconds
138
- setTimeout(() => location.reload(), 20000);
 
139
  };
140
  }
141
 
142
- function startProcess() {
143
- speak("Welcome to Biryani Hub", function() {
144
- speak("Tell me your name", startListeningForName);
145
- });
146
- }
147
-
148
  window.onload = function () {
149
- setTimeout(startProcess, 4000); // Start process after 4 second
150
  };
151
  </script>
152
  </body>
 
8
  <style>
9
  body {
10
  font-family: 'Roboto', sans-serif;
11
+ background: linear-gradient(135deg, #f4c542, #ff8f6a);
12
  margin: 0;
13
  display: flex;
14
  justify-content: center;
 
17
  text-align: center;
18
  }
19
  .container {
20
+ background: lightblue;
21
  padding: 40px 50px;
22
  border-radius: 10px;
23
  width: 400px;
 
26
  h1 {
27
  font-size: 30px;
28
  font-weight: bold;
29
+ color: #ff6a00;
30
  }
31
  label {
32
  font-size: 18px;
 
59
  <div class="container">
60
  <h1>Welcome to Biryani Hub</h1>
61
 
 
62
  <label for="name">Your Name</label>
63
  <input type="text" id="name" placeholder="Your name will appear here..." readonly>
64
 
 
65
  <label for="email">Your Email</label>
66
  <input type="text" id="email" placeholder="Your email will appear here..." readonly>
67
 
 
68
  <p class="info" id="infoMessage">Listening will start automatically...</p>
 
 
69
  <p class="status" id="status">Initializing...</p>
70
  </div>
71
 
72
  <script>
73
  let recognition;
 
74
  let isNameCaptured = false;
75
+ let isEmailCaptured = false;
76
 
77
  if ('webkitSpeechRecognition' in window) {
78
  recognition = new webkitSpeechRecognition();
79
+ recognition.continuous = false;
80
  recognition.interimResults = false;
81
  recognition.lang = 'en-US';
82
  } else {
 
85
 
86
  function speak(text, callback) {
87
  const speech = new SpeechSynthesisUtterance(text);
88
+ speech.onend = callback;
89
  window.speechSynthesis.speak(speech);
90
  }
91
 
92
+ function startProcess() {
93
+ speak("Welcome to Biryani Hub", function() {
94
+ speak("Tell me your name", startListening);
95
+ });
 
 
 
 
 
 
 
 
 
 
 
96
  }
97
 
98
+ function startListening() {
99
  const status = document.getElementById('status');
100
+ const nameInput = document.getElementById('name');
101
  const emailInput = document.getElementById('email');
102
+
 
103
  recognition.start();
 
104
  recognition.onresult = function(event) {
105
+ const transcript = event.results[0][0].transcript.trim();
106
+
107
+ if (isNameCaptured && !isEmailCaptured) {
108
+ const cleanedEmail = transcript.replace(/\s/g, '').replace(' at ', '@');
109
+ emailInput.value = cleanedEmail;
110
+ status.textContent = 'Registration complete.';
111
+ speak("Registration complete. Go to the next step and take the order you want.");
112
+ setTimeout(() => location.reload(), 20000);
113
+ isEmailCaptured = true;
114
+ } else if (!isNameCaptured) {
115
+ nameInput.value = transcript;
116
+ status.textContent = 'Listening for your email...';
117
+ recognition.stop();
118
+ isNameCaptured = true;
119
+ speak("Tell me your email", function() {
120
+ recognition.start();
121
+ });
122
+ }
123
  };
124
  }
125
 
 
 
 
 
 
 
126
  window.onload = function () {
127
+ setTimeout(startProcess, 4000);
128
  };
129
  </script>
130
  </body>