Spaces:
Runtime error
Runtime error
Update templates/index.html
Browse files- templates/index.html +36 -1
templates/index.html
CHANGED
@@ -67,15 +67,50 @@
|
|
67 |
</div>
|
68 |
</body>
|
69 |
<script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
70 |
function speak(text, callback) {
|
71 |
const speech = new SpeechSynthesisUtterance(text);
|
72 |
speech.onend = callback;
|
73 |
window.speechSynthesis.speak(speech);
|
74 |
}
|
75 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
function startProcess() {
|
77 |
speak("Welcome to Biryani Hub", function() {
|
78 |
-
speak("
|
79 |
});
|
80 |
}
|
81 |
|
|
|
67 |
</div>
|
68 |
</body>
|
69 |
<script>
|
70 |
+
let recognition;
|
71 |
+
if ('webkitSpeechRecognition' in window) {
|
72 |
+
recognition = new webkitSpeechRecognition();
|
73 |
+
recognition.continuous = false;
|
74 |
+
recognition.interimResults = false;
|
75 |
+
recognition.lang = 'en-US';
|
76 |
+
} else {
|
77 |
+
alert("Speech Recognition API is not supported in this browser.");
|
78 |
+
}
|
79 |
+
|
80 |
function speak(text, callback) {
|
81 |
const speech = new SpeechSynthesisUtterance(text);
|
82 |
speech.onend = callback;
|
83 |
window.speechSynthesis.speak(speech);
|
84 |
}
|
85 |
|
86 |
+
function startListeningForName() {
|
87 |
+
document.getElementById('status').textContent = "Listening for your name...";
|
88 |
+
recognition.start();
|
89 |
+
|
90 |
+
recognition.onresult = function(event) {
|
91 |
+
const transcript = event.results[0][0].transcript.trim();
|
92 |
+
document.getElementById('name').value = transcript;
|
93 |
+
recognition.stop();
|
94 |
+
speak("Please provide your email address", startListeningForEmail);
|
95 |
+
};
|
96 |
+
}
|
97 |
+
|
98 |
+
function startListeningForEmail() {
|
99 |
+
document.getElementById('status').textContent = "Listening for your email...";
|
100 |
+
recognition.start();
|
101 |
+
|
102 |
+
recognition.onresult = function(event) {
|
103 |
+
let transcript = event.results[0][0].transcript.trim();
|
104 |
+
transcript = transcript.replace(/\bat\b/g, '@').replace(/\bdot\b/g, '.');
|
105 |
+
document.getElementById('email').value = transcript;
|
106 |
+
recognition.stop();
|
107 |
+
speak("Registration complete. You can proceed with your order.");
|
108 |
+
};
|
109 |
+
}
|
110 |
+
|
111 |
function startProcess() {
|
112 |
speak("Welcome to Biryani Hub", function() {
|
113 |
+
speak("Tell me your name", startListeningForName);
|
114 |
});
|
115 |
}
|
116 |
|