lokesh341 commited on
Commit
0e4d29e
·
verified ·
1 Parent(s): 05a9a93

Update templates/index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +101 -72
templates/index.html CHANGED
@@ -4,101 +4,130 @@
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
  <title>Biryani Hub Registration</title>
7
- <link rel="stylesheet" href="{{ url_for('static', filename='styles.css') }}">
8
- </head>
9
- <body>
10
- <div class="container">
11
- <h1>Biryani Hub</h1>
 
 
 
 
 
 
 
12
 
13
- <label for="name">Name:</label>
14
- <input type="text" id="name" readonly>
 
 
 
 
 
15
 
16
- <label for="email">Email:</label>
17
- <input type="text" id="email" readonly>
 
 
 
18
 
19
- <p id="status">Initializing...</p>
20
- <audio id="audio-player" autoplay></audio>
21
- </div>
 
 
 
22
 
23
- <script>
24
- async function playAudio(src) {
25
- const audioPlayer = document.getElementById('audio-player');
26
- audioPlayer.src = src;
27
- await audioPlayer.play();
28
- return new Promise(resolve => {
29
- audioPlayer.onended = resolve;
30
- });
31
  }
32
 
33
- async function recordAudio() {
34
- const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
35
- const mediaRecorder = new MediaRecorder(stream);
36
- let audioChunks = [];
 
 
37
 
38
- return new Promise(resolve => {
39
- mediaRecorder.ondataavailable = event => {
40
- audioChunks.push(event.data);
41
- };
 
 
 
 
 
 
 
 
42
 
43
- mediaRecorder.onstop = () => {
44
- const audioBlob = new Blob(audioChunks, { type: 'audio/wav' });
45
- resolve(audioBlob);
46
- };
47
 
48
- mediaRecorder.start();
49
- setTimeout(() => mediaRecorder.stop(), 5000); // Reduced to 5 seconds for quicker interaction
50
- });
 
51
  }
 
 
 
 
 
 
 
 
 
52
 
53
- async function transcribeAudio(audioBlob) {
54
- const formData = new FormData();
55
- formData.append('audio', audioBlob, 'input.wav');
56
 
57
- const response = await fetch('/transcribe', {
58
- method: 'POST',
59
- body: formData
60
- });
61
 
62
- const result = await response.json();
63
- return result.text || 'Error capturing speech';
64
- }
 
 
 
65
 
66
- async function startInteraction() {
 
 
67
  const status = document.getElementById('status');
68
  const nameInput = document.getElementById('name');
69
  const emailInput = document.getElementById('email');
70
 
71
  status.textContent = 'Playing welcome message...';
72
- await playAudio('{{ url_for("static", filename="welcome.mp3") }}');
73
-
74
- status.textContent = 'Asking for your name...';
75
- await playAudio('{{ url_for("static", filename="ask_name.mp3") }}');
76
-
77
- status.textContent = 'Listening for your name...';
78
- const nameAudio = await recordAudio();
79
- const nameText = await transcribeAudio(nameAudio);
80
- nameInput.value = nameText;
81
-
82
- status.textContent = 'Asking for your email...';
83
- await playAudio('{{ url_for("static", filename="ask_email.mp3") }}');
84
-
85
- status.textContent = 'Listening for your email...';
86
- const emailAudio = await recordAudio();
87
- const emailText = await transcribeAudio(emailAudio);
88
- emailInput.value = emailText;
89
-
90
- status.textContent = 'Playing thank you message...';
91
- await playAudio('{{ url_for("static", filename="thank_you.mp3") }}');
92
-
93
- status.textContent = 'Registration complete.';
94
 
95
- // Auto refresh the page after 15 seconds
96
  setTimeout(() => {
97
- location.reload();
98
- }, 15000); // 15 seconds
 
 
 
 
 
 
99
  }
100
 
101
- window.onload = startInteraction;
102
  </script>
103
  </body>
104
  </html>
 
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
  <title>Biryani Hub Registration</title>
7
+ <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500&display=swap" rel="stylesheet">
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;
15
+ align-items: center;
16
+ height: 100vh;
17
+ text-align: center;
18
+ }
19
 
20
+ .container {
21
+ background: white;
22
+ padding: 40px 50px;
23
+ border-radius: 10px;
24
+ width: 400px;
25
+ box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
26
+ }
27
 
28
+ h1 {
29
+ font-size: 30px;
30
+ font-weight: bold;
31
+ color: #ff6a00; /* Bright orange for title */
32
+ }
33
 
34
+ label {
35
+ font-size: 18px;
36
+ margin-top: 20px;
37
+ display: block;
38
+ text-align: left;
39
+ }
40
 
41
+ input[type="text"] {
42
+ width: 100%;
43
+ padding: 10px;
44
+ font-size: 16px;
45
+ border: 1px solid #ccc;
46
+ border-radius: 5px;
47
+ margin-top: 8px;
 
48
  }
49
 
50
+ .info {
51
+ margin-top: 20px;
52
+ font-size: 16px;
53
+ color: #ff6a00;
54
+ font-weight: bold;
55
+ }
56
 
57
+ .btn {
58
+ margin-top: 30px;
59
+ padding: 12px;
60
+ background-color: #ff6a00;
61
+ color: white;
62
+ font-size: 18px;
63
+ font-weight: bold;
64
+ border: none;
65
+ border-radius: 5px;
66
+ cursor: pointer;
67
+ transition: background-color 0.3s;
68
+ }
69
 
70
+ .btn:hover {
71
+ background-color: #ff5500;
72
+ }
 
73
 
74
+ .status {
75
+ font-size: 14px;
76
+ color: gray;
77
+ margin-top: 20px;
78
  }
79
+ </style>
80
+ </head>
81
+ <body>
82
+ <div class="container">
83
+ <h1>Biryani Hub</h1>
84
+
85
+ <!-- Name Input Field -->
86
+ <label for="name">Name:</label>
87
+ <input type="text" id="name" placeholder="Your name will appear here..." readonly>
88
 
89
+ <!-- Email Input Field -->
90
+ <label for="email">Email:</label>
91
+ <input type="text" id="email" placeholder="Your email will appear here..." readonly>
92
 
93
+ <!-- Info Message for Listening -->
94
+ <p class="info">Listening will start automatically...</p>
 
 
95
 
96
+ <!-- Welcome Button -->
97
+ <button class="btn" id="startListeningBtn">Welcome to Biryani Hub</button>
98
+
99
+ <!-- Status Message -->
100
+ <p class="status" id="status">Initializing...</p>
101
+ </div>
102
 
103
+ <script>
104
+ // This function simulates the speech recognition and fills in the fields after listening
105
+ async function startListening() {
106
  const status = document.getElementById('status');
107
  const nameInput = document.getElementById('name');
108
  const emailInput = document.getElementById('email');
109
 
110
  status.textContent = 'Playing welcome message...';
111
+
112
+ // Simulate listening for name
113
+ setTimeout(() => {
114
+ nameInput.value = "John Doe"; // Simulated name input from voice
115
+ status.textContent = 'Listening for your email...';
116
+ }, 5000);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
117
 
118
+ // Simulate listening for email after 5 seconds
119
  setTimeout(() => {
120
+ emailInput.value = "[email protected]"; // Simulated email input from voice
121
+ status.textContent = 'Registration complete.';
122
+
123
+ // Auto refresh after 15 seconds
124
+ setTimeout(() => {
125
+ location.reload();
126
+ }, 15000); // 15 seconds auto-refresh
127
+ }, 10000);
128
  }
129
 
130
+ document.getElementById('startListeningBtn').addEventListener('click', startListening);
131
  </script>
132
  </body>
133
  </html>