voicemenu143 / templates /index.html
lokesh341's picture
Update templates/index.html
e3eb78d verified
raw
history blame
6.5 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Biryani Hub - Register & Login</title>
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500&display=swap" rel="stylesheet">
<style>
body {
font-family: 'Roboto', sans-serif;
background: linear-gradient(135deg, #f4c542, #ff8f6a);
margin: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
text-align: center;
}
.container {
background-color: #fff;
padding: 40px 50px;
border-radius: 10px;
width: 500px;
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}
h1 {
font-size: 30px;
font-weight: bold;
color: #ff6a00;
}
label {
font-size: 16px;
display: block;
text-align: left;
font-weight: bold;
color: #333;
}
input {
width: 100%;
padding: 10px;
border: 2px solid #ccc;
border-radius: 8px;
margin-top: 8px;
background-color: #f9f9f9;
font-size: 16px;
}
.info {
margin-top: 20px;
font-size: 16px;
color: #ff6a00;
font-weight: bold;
}
.status {
font-size: 14px;
color: gray;
margin-top: 20px;
}
.confirm-button {
padding: 10px 20px;
background-color: #ff6a00;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
}
.confirm-button:hover {
background-color: #e65e00;
}
</style>
</head>
<body>
<div class="container">
<h1>Welcome to Biryani Hub 🍽 πŸ—</h1>
<label>Your Name</label>
<input type="text" id="name" placeholder="Listening..." readonly>
<label>Your Email</label>
<input type="text" id="email" placeholder="Listening..." readonly>
<label>Your Mobile Number</label>
<input type="text" id="mobile" placeholder="Listening..." readonly>
<p class="info" id="infoMessage">Listening πŸ—£πŸŽ™οΈ...</p>
<p class="status" id="status">πŸ”Š...</p>
<button class="confirm-button" onclick="autoSubmit()">Submit</button>
</div>
<script>
let recognition;
let nameCaptured = "";
let emailCaptured = "";
let mobileCaptured = "";
// Check browser support
if ('webkitSpeechRecognition' in window) {
recognition = new webkitSpeechRecognition();
recognition.continuous = false;
recognition.interimResults = false;
recognition.lang = 'en-US';
} else {
alert("Speech Recognition API is not supported in this browser.");
}
function speak(text, callback) {
const speech = new SpeechSynthesisUtterance(text);
speech.onend = callback;
window.speechSynthesis.speak(speech);
}
function startListening() {
recognition.start();
recognition.onresult = function(event) {
let result = event.results[0][0].transcript.trim();
recognition.stop();
handleInput(result);
};
}
function handleInput(input) {
if (!nameCaptured) {
nameCaptured = input;
document.getElementById('name').value = nameCaptured;
speak("You said " + nameCaptured + ". Now, say your email.", startListening);
} else if (!emailCaptured) {
emailCaptured = input.replace(/\bat\b/g, '@').replace(/\s+/g, '');
document.getElementById('email').value = emailCaptured;
speak("You said " + emailCaptured + ". Now, say your mobile number.", startListening);
} else if (!mobileCaptured) {
mobileCaptured = input.replace(/\s+/g, '');
document.getElementById('mobile').value = mobileCaptured;
speak("You said " + mobileCaptured + ". Confirm by saying 'OK'.", confirmSubmission);
}
}
function confirmSubmission() {
recognition.start();
recognition.onresult = function(event) {
let confirmation = event.results[0][0].transcript.trim().toLowerCase();
recognition.stop();
if (confirmation.includes("ok")) {
autoSubmit();
} else {
speak("Let's try again.", startListening);
}
};
}
function autoSubmit() {
var name = document.getElementById('name').value;
var email = document.getElementById('email').value;
var phone = document.getElementById('mobile').value;
// Simulated API request
fetch('https://jsonplaceholder.typicode.com/posts', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ name: name, email: email, phone: phone })
})
.then(response => response.json())
.then(data => {
document.getElementById('status').textContent = 'βœ… Submitted successfully!';
speak("Your details were submitted successfully!");
validateWorldRecords(name, email, phone);
})
.catch(error => {
document.getElementById('status').textContent = '❌ Error submitting!';
speak("There was an error submitting your details.");
});
}
function validateWorldRecords(name, email, phone) {
let worldRecordNames = ["Usain Bolt", "Michael Phelps", "Serena Williams"];
if (worldRecordNames.includes(name)) {
speak("Wow! You are a world record holder!");
} else {
speak("Thank you for registering.");
}
}
window.onload = function () {
speak("Please say your name.", startListening);
};
</script>
</body>
</html>