|
<!DOCTYPE html> |
|
<html lang="en"> |
|
<head> |
|
<meta charset="UTF-8"> |
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"> |
|
<title>π Biryani Hub - Voice Registration</title> |
|
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;600&display=swap" rel="stylesheet"> |
|
<style> |
|
body { |
|
font-family: 'Poppins', sans-serif; |
|
background: linear-gradient(135deg, #ff6f61, #ffcc00); |
|
margin: 0; |
|
padding: 0; |
|
display: flex; |
|
justify-content: center; |
|
align-items: center; |
|
height: 100vh; |
|
color: #333; |
|
} |
|
.container { |
|
background: rgba(255, 255, 255, 0.9); |
|
padding: 2rem; |
|
border-radius: 15px; |
|
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1); |
|
text-align: center; |
|
max-width: 500px; |
|
width: 100%; |
|
} |
|
h1 { |
|
font-size: 2.5rem; |
|
color: #ff6f61; |
|
margin-bottom: 1rem; |
|
} |
|
p { |
|
font-size: 1.1rem; |
|
margin-bottom: 2rem; |
|
} |
|
.btn { |
|
background: #ff6f61; |
|
color: white; |
|
border: none; |
|
padding: 0.8rem 2rem; |
|
font-size: 1rem; |
|
border-radius: 25px; |
|
cursor: pointer; |
|
transition: background 0.3s ease; |
|
} |
|
.btn:hover { |
|
background: #ff4a3d; |
|
} |
|
.status { |
|
margin-top: 1.5rem; |
|
font-size: 0.9rem; |
|
color: #666; |
|
} |
|
.input-field { |
|
margin: 1rem 0; |
|
padding: 0.8rem; |
|
width: 100%; |
|
border: 1px solid #ddd; |
|
border-radius: 5px; |
|
font-size: 1rem; |
|
} |
|
</style> |
|
</head> |
|
<body> |
|
<div class="container"> |
|
<h1>Welcome to Biryani Hub π</h1> |
|
<p>Register using your voice! Click below to start.</p> |
|
|
|
|
|
<input type="text" id="name" class="input-field" placeholder="Your Name" readonly> |
|
<input type="text" id="email" class="input-field" placeholder="Your Email" readonly> |
|
|
|
|
|
<button class="btn" id="startBtn">Start Voice Registration</button> |
|
|
|
|
|
<p class="status" id="status">Press the button and speak clearly.</p> |
|
</div> |
|
|
|
<script> |
|
|
|
async function transcribeSpeech(audioBlob) { |
|
const response = await fetch("https://api-inference.huggingface.co/models/openai/whisper-small", { |
|
headers: { Authorization: "Bearer YOUR_HF_TOKEN" }, |
|
method: "POST", |
|
body: audioBlob, |
|
}); |
|
return await response.json(); |
|
} |
|
|
|
|
|
let isProcessing = false; |
|
const startBtn = document.getElementById('startBtn'); |
|
const status = document.getElementById('status'); |
|
const nameInput = document.getElementById('name'); |
|
const emailInput = document.getElementById('email'); |
|
|
|
startBtn.addEventListener('click', async () => { |
|
if (isProcessing) return; |
|
isProcessing = true; |
|
status.textContent = "Listening... Speak your name letter by letter."; |
|
|
|
try { |
|
const stream = await navigator.mediaDevices.getUserMedia({ audio: true }); |
|
const mediaRecorder = new MediaRecorder(stream); |
|
let audioChunks = []; |
|
|
|
mediaRecorder.ondataavailable = (e) => audioChunks.push(e.data); |
|
mediaRecorder.onstop = async () => { |
|
const audioBlob = new Blob(audioChunks, { type: 'audio/wav' }); |
|
const transcription = await transcribeSpeech(audioBlob); |
|
nameInput.value = transcription.text.toUpperCase(); |
|
status.textContent = "Name captured! Now speak your email."; |
|
}; |
|
|
|
mediaRecorder.start(); |
|
setTimeout(() => mediaRecorder.stop(), 5000); |
|
} catch (error) { |
|
status.textContent = "Error: Microphone access denied."; |
|
} finally { |
|
isProcessing = false; |
|
} |
|
}); |
|
</script> |
|
</body> |
|
</html> |