Spaces:
Sleeping
Sleeping
File size: 2,426 Bytes
4e70d0d cb0a021 4e70d0d cb0a021 4e70d0d cb0a021 4e70d0d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Biryani Hub</title>
<link rel="stylesheet" href="{{ url_for('static', filename='styles.css') }}">
</head>
<body>
<div class="container">
<h1>Biryani Hub</h1>
<label for="name">Name</label>
<input type="text" id="name" placeholder="Your name will appear here..." readonly>
<label for="email">Email</label>
<input type="text" id="email" placeholder="Your email will appear here..." readonly>
<button id="mic-button" onclick="recordAudio()">
🎙️ Click to Speak
</button>
<p class="instructions">Please say your name when ready</p>
<audio id="audio-player" controls></audio>
</div>
<script>
async function playWelcomeAudio() {
let response = await fetch("/get_prompt");
let data = await response.json();
document.getElementById("audio-player").src = data.audio_url;
document.getElementById("audio-player").play();
}
async function recordAudio() {
let stream = await navigator.mediaDevices.getUserMedia({ audio: true });
let mediaRecorder = new MediaRecorder(stream);
let audioChunks = [];
mediaRecorder.ondataavailable = event => {
audioChunks.push(event.data);
};
mediaRecorder.onstop = async () => {
let audioBlob = new Blob(audioChunks, { type: 'audio/wav' });
let formData = new FormData();
formData.append("audio", audioBlob, "input.wav");
let response = await fetch("/process_audio", {
method: "POST",
body: formData
});
let result = await response.json();
document.getElementById("name").value = result.text || result.error;
// Prompt for Email after Name
setTimeout(() => {
let emailPrompt = new Audio("/static/email_prompt.mp3");
emailPrompt.play();
}, 2000);
};
mediaRecorder.start();
setTimeout(() => mediaRecorder.stop(), 4000);
}
window.onload = playWelcomeAudio;
</script>
</body>
</html>
|