geethareddy commited on
Commit
a25e475
·
verified ·
1 Parent(s): 56becc0

Update templates/index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +0 -99
templates/index.html CHANGED
@@ -1,8 +1,5 @@
1
  <!DOCTYPE html>
2
  <html lang="en">
3
- <head>
4
- <meta charsa<!DOCTYPE html>
5
- <html lang="en">
6
  <head>
7
  <meta charset="UTF-8">
8
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
@@ -100,99 +97,3 @@
100
  </script>
101
  </body>
102
  </html>
103
- et="UTF-8">
104
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
105
- <title>Biryani Hub Registration</title>
106
- <link rel="stylesheet" href="{{ url_for('static', filename='styles.css') }}">
107
- </head>
108
- <body>
109
- <div class="container">
110
- <h1>Biryani Hub</h1>
111
-
112
- <label for="name">Name:</label>
113
- <input type="text" id="name" readonly>
114
-
115
- <label for="email">Email:</label>
116
- <input type="text" id="email" readonly>
117
-
118
- <p id="status">Initializing...</p>
119
- <audio id="audio-player" autoplay></audio>
120
- </div>
121
-
122
- <script>
123
- async function playAudio(src) {
124
- const audioPlayer = document.getElementById('audio-player');
125
- audioPlayer.src = src;
126
- await audioPlayer.play();
127
- return new Promise(resolve => {
128
- audioPlayer.onended = resolve;
129
- });
130
- }
131
-
132
- async function recordAudio() {
133
- const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
134
- const mediaRecorder = new MediaRecorder(stream);
135
- let audioChunks = [];
136
-
137
- return new Promise(resolve => {
138
- mediaRecorder.ondataavailable = event => {
139
- audioChunks.push(event.data);
140
- };
141
-
142
- mediaRecorder.onstop = () => {
143
- const audioBlob = new Blob(audioChunks, { type: 'audio/wav' });
144
- resolve(audioBlob);
145
- };
146
-
147
- mediaRecorder.start();
148
- setTimeout(() => mediaRecorder.stop(), 7000); // Record for 7 seconds
149
- });
150
- }
151
-
152
- async function transcribeAudio(audioBlob) {
153
- const formData = new FormData();
154
- formData.append('audio', audioBlob, 'input.wav');
155
-
156
- const response = await fetch('/transcribe', {
157
- method: 'POST',
158
- body: formData
159
- });
160
-
161
- const result = await response.json();
162
- return result.text || 'Error capturing speech';
163
- }
164
-
165
- async function startInteraction() {
166
- const status = document.getElementById('status');
167
- const nameInput = document.getElementById('name');
168
- const emailInput = document.getElementById('email');
169
-
170
- status.textContent = 'Playing welcome message...';
171
- await playAudio('{{ url_for("static", filename="welcome.mp3") }}');
172
-
173
- status.textContent = 'Asking for your name...';
174
- await playAudio('{{ url_for("static", filename="ask_name.mp3") }}');
175
-
176
- status.textContent = 'Listening for your name...';
177
- const nameAudio = await recordAudio();
178
- const nameText = await transcribeAudio(nameAudio);
179
- nameInput.value = nameText;
180
-
181
- status.textContent = 'Asking for your email...';
182
- await playAudio('{{ url_for("static", filename="ask_email.mp3") }}');
183
-
184
- status.textContent = 'Listening for your email...';
185
- const emailAudio = await recordAudio();
186
- const emailText = await transcribeAudio(emailAudio);
187
- emailInput.value = emailText;
188
-
189
- status.textContent = 'Playing thank you message...';
190
- await playAudio('{{ url_for("static", filename="thank_you.mp3") }}');
191
-
192
- status.textContent = 'Registration complete.';
193
- }
194
-
195
- window.onload = startInteraction;
196
- </script>
197
- </body>
198
- </html>
 
1
  <!DOCTYPE html>
2
  <html lang="en">
 
 
 
3
  <head>
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
 
97
  </script>
98
  </body>
99
  </html>