Built for the Connecting Dreams Foundation Round 2 Technical Assignment
boundary event, which fires as the speech engine crosses each word and reports a charIndex. That index is mapped to a word position, and the matching <span> is highlighted. Two notes on reliability:boundary event support varies by browser/OS/voice combination, especially for non-Latin-script voices like hi-IN — on some platforms it doesn't fire at all. When it doesn't, speech still plays normally; the text just isn't highlighted. There's no broken state, only a graceful absence of the effect.en-IN and not hi-IN for speech recognition: an earlier version used hi-IN, which transcribes English loanwords like "quiz" into Devanagari script or phonetic spellings — silently breaking keyword-based command detection (the app would fall through to "explain" instead of recognizing "quiz"). en-IN keeps English command words in Latin script while still recognizing common Hindi words phonetically, which matters far more for a command-driven app than perfect Hindi transcription accuracy. Command detection itself still matches both Latin-script and Devanagari keywords as a safety net (क्विज, सवाल, पाठ योजना, etc.) in case the recognizer guesses a Hindi-heavy utterance anyway.utils/format.js) — minor words like "of"/"the"/"a" stay lowercase unless they're the first word, so "laws of motion" reads naturally instead of "Laws Of Motion."groq-sdk) — Llama 3.3 70B, JSON mode (response_format: json_object) for structured bilingual output Diagrams Mermaid.js — rendered live from AI-generated syntax, sanitized server-side Speech-to-Text Browser Web Speech API, en-IN locale (free, no API key) Text-to-Speech Browser SpeechSynthesis API, hi-IN voice (free, no API key) Logging morgan (HTTP request logging) Database None (stateless; session stored in memory)response_format: { type: "json_object" }) alongside an explicit schema in the prompt — this combination is far more reliable than prompt instructions alone, which is what the earlier prose-based explanation prompt relied on. Grade-level instruction ensures age-appropriate language in both languages equally. The bilingual requirement means a teacher (or evaluator) can read the same content in whichever language suits the moment, while Hinglish stays the default and the only one spoken aloud via TTS. The diagram prompt is intentionally separated from the explanation prompt and run in parallel — if diagram generation fails or the model returns malformed Mermaid syntax, the explanation still succeeds (diagram is best-effort, not blocking).concept, example, activity, quiz, homework) removes that failure mode structurally: the model physically cannot merge sections, because they're separate JSON keys, not parts of one string it has to remember to break up correctly.sanitizeMermaid() cleaner and rejects anything that still doesn't start with a valid graph TD header rather than passing it through. The standalone /api/diagram regenerate endpoint also retries once at a lower temperature before giving up. If no valid diagram comes back, the UI shows a clear "Diagram nahi bana" state with a one-tap "Diagram Banao" retry button instead of a silent gap or a broken render.en-IN (keeps English command words in Latin script for reliable detection) while speech synthesis uses hi-IN (natural-sounding spoken Hinglish). This is intentional, not an oversight — see Voice Command Detection above for why hi-IN recognition silently broke command matching.speechSynthesis.cancel() does not reliably fire onend across browsers (Safari fires onerror instead; Chrome is inconsistent on long utterances), so a naive "speak next question when this one ends" chain can keep talking even after the teacher hits Stop. useSpeech's speakSequence() assigns each readout an incrementing token; every step checks the token is still current before speaking the next item, so stopping mid-quiz reliably halts the whole sequence instead of just the current sentence.en-IN locale — keeps English command words ("quiz", "explain", "lesson plan") in Latin script so voice commands are detected reliably; still recognizes common Hindi words phoneticallyhi-IN voice — always speaks the Hinglish version aloud, since that's the natural spoken register for a Haryana classroomhttp://localhost:5173 in Chrome (required for Web Speech API)./frontend/backend, add GROQ_API_KEY env varVITE_API_URL=https://your-render-url.onrender.com/api in Vercel env vars.Posted Aug 6, 2026
Developed a voice-enabled AI teaching assistant for government schools.