Back
Home
Courses
Registration
Pages
Quran Teacher
Community
Research
Iman Ranking
Events
Non Muslims
Portfolio
Portfolio 2
About Us
FAQs
Become a Teacher
404 Page
Maintenance
Blog
Shop
Contact
Home
Courses
Registration
Pages
Quran Teacher
Community
Research
Iman Ranking
Events
Non Muslims
Portfolio
Portfolio 2
About Us
FAQs
Become a Teacher
404 Page
Maintenance
Blog
Shop
Contact
Cart
Home
Cart
Your cart is currently empty.
Return to shop
// === Voice Quiz Enhancer for Watu Pro === // Adds TTS (reads the question) and STT (speech input for answers) document.addEventListener("DOMContentLoaded", () => { const speak = (text) => { const utterance = new SpeechSynthesisUtterance(text); utterance.lang = 'en-US'; speechSynthesis.speak(utterance); }; const recognition = new (window.SpeechRecognition || window.webkitSpeechRecognition)(); recognition.lang = 'en-US'; recognition.continuous = false; recognition.interimResults = false; // Speak question + choices const questionBlock = document.querySelector(".watu-question"); if (questionBlock) { const textToSpeak = questionBlock.innerText.replace(/\s+/g, " "); speak(textToSpeak); } // Listen for spoken answers recognition.onresult = function (event) { const transcript = event.results[0][0].transcript.toLowerCase(); let selected = false; ['a', 'b', 'c', 'd'].forEach(letter => { if (transcript.includes(letter) && !selected) { const label = document.querySelector(`label[for*=answer_${letter}]`); if (label) { label.click(); // Simulate clicking the label (selects answer) selected = true; speak(`You selected option ${letter.toUpperCase()}`); const submitBtn = document.querySelector("input[type='submit']"); if (submitBtn) { setTimeout(() => submitBtn.click(), 1000); // Auto-submit } } } }); if (!selected) speak("Sorry, I didn't catch that. Please say A, B, C, or D."); }; // Start recognition on button click const listenBtn = document.createElement("button"); listenBtn.textContent = "🎤 Answer by Voice"; listenBtn.style.marginTop = "10px"; listenBtn.onclick = () => { recognition.start(); speak("Listening for your answer."); }; const container = document.querySelector(".watu-question")?.parentElement; if (container) container.appendChild(listenBtn); });
Login with your site account
Lost your password?
Remember Me