{"id":1743,"date":"2024-09-30T04:05:24","date_gmt":"2024-09-30T04:05:24","guid":{"rendered":"https:\/\/phamho.com\/book\/?p=1743"},"modified":"2024-09-30T04:06:17","modified_gmt":"2024-09-30T04:06:17","slug":"chinese-wh-questions-family","status":"publish","type":"post","link":"https:\/\/phamho.com\/book\/chinese-wh-questions-family\/","title":{"rendered":"Chinese WH-Questions &#8211; Family"},"content":{"rendered":"\n<!DOCTYPE html>\n<html lang=\"zh\">\n<head>\n    <meta charset=\"UTF-8\">\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n    <title>Chinese WH-Questions &#8211; Family<\/title>\n    <style>\n        body {\n            font-family: Arial, sans-serif;\n            background-color: #ffffff;\n            margin: 0;\n            padding: 0;\n            display: flex;\n            flex-direction: column; \/* Stack elements vertically *\/\n            min-height: 100vh;\n        }\n        .menu {\n            width: 100%;\n            background-color: #d97b0f;\n            padding: 10px;\n            text-align: center;\n            box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);\n            flex-shrink: 0;\n            overflow-x: auto;\n            white-space: nowrap;\n        }\n        .menu a {\n            color: #fff;\n            text-decoration: none;\n            margin: 0 8px;\n            font-weight: bold;\n            font-size: 14px;\n            display: inline-block;\n        }\n        .menu a:hover {\n            text-decoration: underline;\n        }\n        .container {\n            display: flex;\n            flex-wrap: wrap;\n            flex: 1 0 auto;\n            padding: 10px;\n            box-sizing: border-box;\n            justify-content: center;\n        }\n        .image-container, .chat-container {\n            width: 100%;\n            max-width: 600px;\n            margin-bottom: 20px;\n        }\n        .image-container {\n            text-align: center;\n        }\n        .image-container img {\n            width: 100%;\n            height: auto;\n            border-radius: 20px;\n            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);\n        }\n        .question-text {\n            margin: 10px 0;\n            font-weight: bold;\n            color: #333;\n            font-size: 16px;\n        }\n        .wh-question-box {\n            margin-top: 10px;\n            padding: 10px;\n            background-color: #fff;\n            border: 2px solid #026c96;\n            border-radius: 10px;\n            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);\n            font-size: 18px;\n            font-weight: bold;\n            color: #026c96;\n            text-align: left;\n            max-height: 300px;\n            overflow-y: auto;\n        }\n        .chat-container {\n            background-color: #026c96;\n            border-radius: 20px;\n            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);\n            overflow: hidden;\n            position: relative;\n        }\n        .chat-header {\n            background-color: #d97b0f;\n            color: #fff;\n            padding: 10px;\n            text-align: center;\n            border-bottom: 1px solid #69010a;\n        }\n        .chat-header h2 {\n            margin: 0;\n            font-size: 18px;\n        }\n        .progress-container {\n            width: 100%;\n            background-color: #e0e0e0;\n            border-radius: 10px;\n            margin: 10px 0;\n            height: 10px;\n        }\n        .progress-bar {\n            width: 0%;\n            height: 100%;\n            background-color: #76c7c0;\n            border-radius: 10px;\n            transition: width 0.3s;\n        }\n        .chat-messages {\n            padding: 10px;\n            overflow-y: auto;\n            max-height: 300px;\n            background-color: #fff;\n        }\n        .message {\n            margin-bottom: 10px;\n            padding: 10px;\n            border-radius: 5px;\n            font-size: 14px;\n            line-height: 1.4;\n        }\n        .user-message {\n            background-color: #4caf50;\n            color: #fff;\n            text-align: right;\n        }\n        .bot-message {\n            background-color: #2196f3;\n            color: #fff;\n            text-align: left;\n        }\n        .chat-input {\n            display: flex;\n            align-items: center;\n            background-color: #a3e106;\n            padding: 10px;\n            justify-content: center;\n        }\n        .send-button, .stop-button, .replay-button {\n            background-color: #17c686;\n            color: #fff;\n            font-weight: bold;\n            border: none;\n            border-radius: 5px;\n            padding: 8px 10px;\n            cursor: pointer;\n            transition: background-color 0.3s;\n            flex: 1;\n            margin: 0 5px;\n            max-width: 150px;\n            font-size: 14px;\n        }\n        .stop-button {\n            background-color: #c86722;\n        }\n        .replay-button {\n            background-color: #2196f3;\n        }\n        .chat-input input {\n            flex: 2;\n            padding: 8px;\n            margin-right: 10px;\n            border: 2px solid #026c96;\n            border-radius: 5px;\n            font-size: 16px;\n        }\n\n        \/* Adjustments for smaller screens *\/\n        @media (max-width: 600px) {\n            .menu a {\n                margin: 0 5px;\n                font-size: 12px;\n            }\n            .question-text {\n                font-size: 14px;\n            }\n            .wh-question-box {\n                font-size: 14px;\n                max-height: 200px;\n            }\n            .chat-header h2 {\n                font-size: 16px;\n            }\n            .chat-messages {\n                max-height: 200px;\n            }\n            .message {\n                font-size: 13px;\n            }\n            .send-button, .stop-button, .replay-button {\n                padding: 6px 8px;\n                font-size: 12px;\n                max-width: 120px;\n            }\n            .chat-input input {\n                font-size: 14px;\n            }\n        }\n        @media (max-width: 400px) {\n            .menu a {\n                margin: 0 3px;\n                font-size: 11px;\n            }\n            .question-text {\n                font-size: 13px;\n            }\n            .wh-question-box {\n                font-size: 13px;\n                max-height: 150px;\n            }\n            .chat-header h2 {\n                font-size: 14px;\n            }\n            .chat-messages {\n                max-height: 150px;\n            }\n            .message {\n                font-size: 12px;\n            }\n            .send-button, .stop-button, .replay-button {\n                padding: 5px 6px;\n                font-size: 11px;\n                max-width: 100px;\n            }\n            .chat-input input {\n                font-size: 12px;\n            }\n        }\n    <\/style>\n<\/head>\n<body>\n    <div class=\"menu\">\n        <a href=\"https:\/\/phamho.com\/book\/2024\/09\/30\/chinese-vocabulary-family\/\">Vocabulary<\/a>\n        <a href=\"https:\/\/phamho.com\/book\/2024\/09\/30\/chinese-sentences-family\/\">Sentences<\/a>\n        <a href=\"https:\/\/phamho.com\/book\/2024\/09\/30\/chinese-yes-no-questions-family\/\">Yes\/No Questions<\/a>\n        <a href=\"https:\/\/phamho.com\/book\/2024\/09\/30\/chinese-likes-family\/\">Like Questions<\/a>\n        <a href=\"https:\/\/phamho.com\/book\/2024\/09\/30\/chinese-wh-questions-family\/\">WH Questions<\/a>   \n    <\/div>\n\n    <div class=\"container\">\n        <div class=\"image-container\">\n            <img decoding=\"async\" src=\"https:\/\/phamho.com\/book\/wp-content\/uploads\/2024\/09\/DALL\u00b7E-2024-09-15-18.17.33-A-classroom-scene-where-advanced-robots-are-teaching-English-to-B1-level-students.-The-robots-have-a-humanoid-design-with-sleek-metallic-bodies-and-f.webp\" alt=\"Lesson Robot\">\n            <div class=\"question-text\">Check the questions and sample answers in this box<\/div>\n            <div id=\"wh-question-box\" class=\"wh-question-box\">\n                <!-- Learned family-related WH questions and sample answers will be displayed here -->\n            <\/div>\n        <\/div>\n        <div class=\"chat-container\">\n            <div class=\"chat-header\">  \n              <h2>Chinese WH-Questions &#8211; Family<\/h2>\n            <\/div>\n            <div class=\"progress-container\">\n                <div id=\"progress-bar\" class=\"progress-bar\"><\/div>\n            <\/div>\n            <div class=\"chat-messages\" id=\"chat-messages\">\n                <!-- Messages will appear here -->\n            <\/div>\n            <div class=\"chat-input\">\n                <input type=\"text\" id=\"user-input\" placeholder=\"Type your answer here...\" style=\"display: none;\" \/>\n                <button id=\"submit-btn\" class=\"send-button\" style=\"display: none;\">Submit<\/button>\n                <button id=\"replay-btn\" class=\"replay-button\" style=\"display: none;\">Replay<\/button>\n                <button id=\"start-btn\" class=\"send-button\">Start Lesson<\/button>\n                <button id=\"stop-btn\" class=\"stop-button\">Stop<\/button>\n            <\/div>\n        <\/div>\n    <\/div>\n\n    <script>\n    const whQuestions = [\n        { \n            question: \"\u4f60\u53eb\u4ec0\u4e48\u540d\u5b57\uff1f\", \n            translation: \"What is your name?\", \n            keywords: [\"\u540d\u5b57\", \"\u4f60\", \"\u53eb\"], \n            sampleAnswer: \"\u6211\u53eb\u674e\u534e\u3002\",\n            sampleTranslation: \"My name is Li Hua.\"\n        },\n        { \n            question: \"\u4f60\u6709\u51e0\u4e2a\u5144\u5f1f\u59d0\u59b9\uff1f\", \n            translation: \"How many siblings do you have?\", \n            keywords: [\"\u5144\u5f1f\", \"\u59d0\u59b9\", \"\u51e0\u4e2a\"], \n            sampleAnswer: \"\u6211\u6709\u4e24\u4e2a\u5144\u5f1f\u548c\u4e00\u4e2a\u59d0\u59d0\u3002\",\n            sampleTranslation: \"I have two brothers and one sister.\"\n        },\n        { \n            question: \"\u4f60\u7236\u6bcd\u662f\u8c01\uff1f\", \n            translation: \"Who are your parents?\", \n            keywords: [\"\u7236\u6bcd\", \"\u662f\u8c01\"], \n            sampleAnswer: \"\u6211\u7684\u7236\u6bcd\u662f\u5f20\u4f1f\u548c\u738b\u82b3\u3002\",\n            sampleTranslation: \"My parents are Zhang Wei and Wang Fang.\"\n        },\n        { \n            question: \"\u4f60\u6709\u51e0\u4e2a\u5b69\u5b50\uff1f\", \n            translation: \"How many children do you have?\", \n            keywords: [\"\u5b69\u5b50\", \"\u51e0\u4e2a\"], \n            sampleAnswer: \"\u6211\u6709\u4e00\u4e2a\u513f\u5b50\u548c\u4e00\u4e2a\u5973\u513f\u3002\",\n            sampleTranslation: \"I have one son and one daughter.\"\n        },\n        { \n            question: \"\u4f60\u7684\u4e08\u592b\/\u59bb\u5b50\u505a\u4ec0\u4e48\u5de5\u4f5c\uff1f\", \n            translation: \"What does your husband\/wife do for a living?\", \n            keywords: [\"\u4e08\u592b\", \"\u59bb\u5b50\", \"\u5de5\u4f5c\"], \n            sampleAnswer: \"\u6211\u7684\u59bb\u5b50\u662f\u4e00\u540d\u6559\u5e08\u3002\",\n            sampleTranslation: \"My wife is a teacher.\"\n        },\n        { \n            question: \"\u4f60\u6700\u559c\u6b22\u7684\u5bb6\u5ead\u6210\u5458\u662f\u8c01\uff1f\", \n            translation: \"Who is your favorite family member?\", \n            keywords: [\"\u559c\u6b22\", \"\u5bb6\u5ead\u6210\u5458\", \"\u662f\u8c01\"], \n            sampleAnswer: \"\u6211\u6700\u559c\u6b22\u6211\u7684\u59b9\u59b9\u3002\",\n            sampleTranslation: \"My favorite is my younger sister.\"\n        },\n        { \n            question: \"\u4f60\u5bb6\u4f4f\u5728\u54ea\u91cc\uff1f\", \n            translation: \"Where does your family live?\", \n            keywords: [\"\u5bb6\", \"\u4f4f\", \"\u54ea\u91cc\"], \n            sampleAnswer: \"\u6211\u5bb6\u4f4f\u5728\u5317\u4eac\u3002\",\n            sampleTranslation: \"My family lives in Beijing.\"\n        },\n        { \n            question: \"\u4f60\u6709\u7956\u7236\u6bcd\u5417\uff1f\", \n            translation: \"Do you have grandparents?\", \n            keywords: [\"\u7956\u7236\u6bcd\", \"\u6709\u5417\"], \n            sampleAnswer: \"\u662f\u7684\uff0c\u6211\u6709\u7956\u7236\u548c\u7956\u6bcd\u3002\",\n            sampleTranslation: \"Yes, I have my grandfather and grandmother.\"\n        },\n        { \n            question: \"\u4f60\u559c\u6b22\u548c\u5bb6\u4eba\u4e00\u8d77\u505a\u4ec0\u4e48\uff1f\", \n            translation: \"What do you like to do with your family?\", \n            keywords: [\"\u559c\u6b22\", \"\u5bb6\u4eba\", \"\u505a\"], \n            sampleAnswer: \"\u6211\u559c\u6b22\u548c\u5bb6\u4eba\u4e00\u8d77\u770b\u7535\u5f71\u3002\",\n            sampleTranslation: \"I like to watch movies with my family.\"\n        },\n        { \n            question: \"\u4f60\u5bb6\u91cc\u6709\u5ba0\u7269\u5417\uff1f\", \n            translation: \"Do you have pets at home?\", \n            keywords: [\"\u5bb6\u91cc\", \"\u5ba0\u7269\", \"\u6709\u5417\"], \n            sampleAnswer: \"\u662f\u7684\uff0c\u6211\u5bb6\u6709\u4e00\u53ea\u72d7\u3002\",\n            sampleTranslation: \"Yes, I have a dog at home.\"\n        },\n        { \n            question: \"\u4f60\u901a\u5e38\u4ec0\u4e48\u65f6\u5019\u548c\u5bb6\u4eba\u4e00\u8d77\u5403\u996d\uff1f\", \n            translation: \"When do you usually eat meals with your family?\", \n            keywords: [\"\u901a\u5e38\", \"\u4ec0\u4e48\u65f6\u5019\", \"\u5403\u996d\"], \n            sampleAnswer: \"\u6211\u4eec\u901a\u5e38\u5728\u665a\u4e0a\u516d\u70b9\u4e00\u8d77\u5403\u996d\u3002\",\n            sampleTranslation: \"We usually eat meals together at 6 PM.\"\n        },\n        { \n            question: \"\u4f60\u7684\u5144\u5f1f\u59d0\u59b9\u505a\u4ec0\u4e48\u5de5\u4f5c\uff1f\", \n            translation: \"What do your siblings do for work?\", \n            keywords: [\"\u5144\u5f1f\u59d0\u59b9\", \"\u505a\", \"\u5de5\u4f5c\"], \n            sampleAnswer: \"\u6211\u7684\u54e5\u54e5\u662f\u4e00\u540d\u5de5\u7a0b\u5e08\uff0c\u6211\u7684\u59d0\u59d0\u662f\u533b\u751f\u3002\",\n            sampleTranslation: \"My brother is an engineer, and my sister is a doctor.\"\n        },\n        { \n            question: \"\u4f60\u5bb6\u4eba\u6700\u559c\u6b22\u7684\u6d3b\u52a8\u662f\u4ec0\u4e48\uff1f\", \n            translation: \"What is your family's favorite activity?\", \n            keywords: [\"\u5bb6\u4eba\", \"\u6700\u559c\u6b22\", \"\u6d3b\u52a8\"], \n            sampleAnswer: \"\u6211\u4eec\u6700\u559c\u6b22\u4e00\u8d77\u65c5\u884c\u3002\",\n            sampleTranslation: \"Our favorite activity is traveling together.\"\n        },\n        { \n            question: \"\u4f60\u7684\u5b69\u5b50\u559c\u6b22\u4ec0\u4e48\uff1f\", \n            translation: \"What do your children like?\", \n            keywords: [\"\u5b69\u5b50\", \"\u559c\u6b22\", \"\u4ec0\u4e48\"], \n            sampleAnswer: \"\u4ed6\u4eec\u559c\u6b22\u73a9\u8db3\u7403\u548c\u753b\u753b\u3002\",\n            sampleTranslation: \"They like playing football and drawing.\"\n        },\n        { \n            question: \"\u4f60\u5bb6\u91cc\u6709\u8001\u4eba\u5417\uff1f\", \n            translation: \"Are there elderly people in your family?\", \n            keywords: [\"\u5bb6\u91cc\", \"\u8001\u4eba\", \"\u6709\u5417\"], \n            sampleAnswer: \"\u662f\u7684\uff0c\u6211\u4eec\u6709\u7237\u7237\u548c\u5976\u5976\u3002\",\n            sampleTranslation: \"Yes, we have grandpa and grandma.\"\n        },\n        { \n            question: \"\u4f60\u548c\u5bb6\u4eba\u7ecf\u5e38\u65c5\u884c\u5417\uff1f\", \n            translation: \"Do you often travel with your family?\", \n            keywords: [\"\u7ecf\u5e38\", \"\u65c5\u884c\", \"\u5bb6\u4eba\"], \n            sampleAnswer: \"\u662f\u7684\uff0c\u6211\u4eec\u6bcf\u5e74\u90fd\u4f1a\u53bb\u4e0d\u540c\u7684\u5730\u65b9\u65c5\u884c\u3002\",\n            sampleTranslation: \"Yes, we travel to different places every year.\"\n        },\n        { \n            question: \"\u4f60\u7684\u5bb6\u5ead\u6210\u5458\u6709\u4ec0\u4e48\u7231\u597d\uff1f\", \n            translation: \"What hobbies do your family members have?\", \n            keywords: [\"\u5bb6\u5ead\u6210\u5458\", \"\u7231\u597d\"], \n            sampleAnswer: \"\u6211\u7684\u7236\u6bcd\u559c\u6b22\u9605\u8bfb\u548c\u56ed\u827a\uff0c\u6211\u6709\u4e00\u4e2a\u559c\u6b22\u97f3\u4e50\u7684\u54e5\u54e5\u3002\",\n            sampleTranslation: \"My parents enjoy reading and gardening, and I have a brother who loves music.\"\n        },\n        { \n            question: \"\u4f60\u6700\u559c\u6b22\u7684\u5bb6\u5ead\u4f20\u7edf\u662f\u4ec0\u4e48\uff1f\", \n            translation: \"What is your favorite family tradition?\", \n            keywords: [\"\u6700\u559c\u6b22\", \"\u5bb6\u5ead\u4f20\u7edf\"], \n            sampleAnswer: \"\u6211\u6700\u559c\u6b22\u7684\u4f20\u7edf\u662f\u6bcf\u5e74\u6625\u8282\u5168\u5bb6\u56e2\u805a\u3002\",\n            sampleTranslation: \"My favorite tradition is the family reunion during Chinese New Year.\"\n        },\n        { \n            question: \"\u4f60\u548c\u5bb6\u4eba\u4e00\u8d77\u5e86\u795d\u54ea\u4e9b\u8282\u65e5\uff1f\", \n            translation: \"Which festivals do you celebrate with your family?\", \n            keywords: [\"\u5e86\u795d\", \"\u8282\u65e5\", \"\u5bb6\u4eba\"], \n            sampleAnswer: \"\u6211\u4eec\u4e00\u8d77\u5e86\u795d\u6625\u8282\u3001\u4e2d\u79cb\u8282\u548c\u7aef\u5348\u8282\u3002\",\n            sampleTranslation: \"We celebrate Chinese New Year, Mid-Autumn Festival, and Dragon Boat Festival together.\"\n        },\n        { \n            question: \"\u4f60\u5bb6\u4eba\u559c\u6b22\u5403\u4ec0\u4e48\u98df\u7269\uff1f\", \n            translation: \"What food does your family like to eat?\", \n            keywords: [\"\u5bb6\u4eba\", \"\u559c\u6b22\", \"\u5403\", \"\u4ec0\u4e48\"], \n            sampleAnswer: \"\u4ed6\u4eec\u559c\u6b22\u5403\u706b\u9505\u548c\u997a\u5b50\u3002\",\n            sampleTranslation: \"They like to eat hotpot and dumplings.\"\n        },\n    ];\n\n    let currentQuestionIndex = 0;\n    let repeatAttempts = 0;\n    let score = 0;\n    let isSpeechRecognitionSupported = false;\n    let recognition;\n\n    \/\/ Updated stop keywords to include Chinese farewells\n    const stopKeywords = [\"\u518d\u89c1\", \"goodbye\", \"good bye\", \"bye\", \"bye bye\", \"byebye\", \"see you\", \"chao\"];\n    const speechSynthesisSupported = 'speechSynthesis' in window;\n\n    \/\/ Feature detection for Speech Recognition\n    if (window.SpeechRecognition || window.webkitSpeechRecognition) {\n        isSpeechRecognitionSupported = true;\n        recognition = new (window.SpeechRecognition || window.webkitSpeechRecognition)();\n        recognition.lang = 'zh-CN'; \/\/ Set to Mandarin Chinese\n        recognition.interimResults = false;\n        recognition.maxAlternatives = 1;\n    }\n\n    window.onload = function() {\n        if (speechSynthesisSupported) {\n            if (window.speechSynthesis.getVoices().length === 0) {\n                \/\/ Voices not loaded yet, wait for the event\n                window.speechSynthesis.onvoiceschanged = function() {\n                    greetUser();\n                };\n            } else {\n                \/\/ Voices already loaded\n                greetUser();\n            }\n        } else {\n            \/\/ Replace alert with in-page notification for better UX\n            displayNotification('\u62b1\u6b49\uff0c\u60a8\u7684\u6d4f\u89c8\u5668\u4e0d\u652f\u6301\u8bed\u97f3\u5408\u6210\u529f\u80fd\u3002\u8bf7\u4f7f\u7528\u517c\u5bb9\u7684\u6d4f\u89c8\u5668\u4ee5\u83b7\u5f97\u6700\u4f73\u4f53\u9a8c\u3002');\n            appendMessage('\u60a8\u7684\u6d4f\u89c8\u5668\u4e0d\u652f\u6301\u8bed\u97f3\u5408\u6210\u529f\u80fd\u3002', 'bot');\n        }\n\n        if (!isSpeechRecognitionSupported) {\n            \/\/ Show text input, submit button, and replay button\n            document.getElementById('user-input').style.display = 'block';\n            document.getElementById('submit-btn').style.display = 'block';\n            document.getElementById('replay-btn').style.display = 'block';\n        } else {\n            \/\/ Hide replay button initially as it's hidden by default\n            document.getElementById('replay-btn').style.display = 'none';\n        }\n\n        \/\/ Load saved progress if available\n        const savedIndex = localStorage.getItem('currentQuestionIndex');\n        const savedScore = localStorage.getItem('score');\n        if (savedIndex !== null) {\n            currentQuestionIndex = parseInt(savedIndex, 10);\n            score = parseInt(savedScore, 10);\n            updateProgress();\n        }\n    };\n\n    function greetUser() {\n        let greeting = \"\u6b22\u8fce\uff01\u5728\u672c\u8bfe\u7a0b\u4e2d\uff0c\u60a8\u5c06\u5b66\u4e6020\u4e2a\u5173\u4e8e\u5bb6\u5ead\u7684\u7b80\u5355\u4e2d\u6587\u7591\u95ee\u53e5\u3002\u6211\u5c06\u95ee\u6bcf\u4e2a\u95ee\u9898\uff0c\u60a8\u9700\u8981\u7528\u4e2d\u6587\u56de\u7b54\u3002\u8bf7\u5c3d\u91cf\u51c6\u786e\u56de\u7b54\u3002\";\n        if (!isSpeechRecognitionSupported) {\n            greeting += \" \u60a8\u7684\u6d4f\u89c8\u5668\u4e0d\u652f\u6301\u8bed\u97f3\u8f93\u5165\uff0c\u8bf7\u5728\u4e0b\u65b9\u6587\u672c\u6846\u4e2d\u8f93\u5165\u60a8\u7684\u56de\u7b54\u3002\";\n        }\n        greeting += \" \u51c6\u5907\u597d\u4e86\u5417\uff1f\u70b9\u51fb\u5f00\u59cb\u8bfe\u7a0b\u4ee5\u5f00\u59cb\u3002\";\n        appendMessage(greeting, 'bot');\n        sayText(greeting, 'zh-CN');\n    }\n\n    document.getElementById('start-btn').onclick = function() {\n        currentQuestionIndex = 0;\n        repeatAttempts = 0;\n        score = 0;\n        \/\/ Clear the question box when starting the lesson\n        clearWhQuestionBox();\n        updateProgress();\n        startWhQuestionLesson();\n    };\n\n    document.getElementById('stop-btn').onclick = function() {\n        endLesson(true); \/\/ Stop the lesson when \"Stop\" button is clicked\n    };\n\n    \/\/ Handle submit button click\n    document.getElementById('submit-btn').onclick = function() {\n        let userInput = document.getElementById('user-input').value.trim();\n        document.getElementById('user-input').value = '';\n        if (userInput) {\n            processUserResponse(userInput);\n        }\n    };\n\n    \/\/ Handle replay button click\n    document.getElementById('replay-btn').onclick = function() {\n        if (currentQuestionIndex < whQuestions.length) {\n            const currentQuestion = whQuestions[currentQuestionIndex].question;\n            sayText(currentQuestion, \"zh-CN\");\n        }\n    };\n\n    \/\/ Allow pressing 'Enter' to submit the answer\n    document.getElementById('user-input').addEventListener('keypress', function(event) {\n        if (event.key === 'Enter') {\n            event.preventDefault();\n            document.getElementById('submit-btn').click();\n        }\n    });\n\n    function startWhQuestionLesson() {\n        if (currentQuestionIndex < whQuestions.length) {\n            const currentQuestion = whQuestions[currentQuestionIndex].question;\n            const translation = whQuestions[currentQuestionIndex].translation;\n            const sampleAnswer = whQuestions[currentQuestionIndex].sampleAnswer;\n            const sampleTranslation = whQuestions[currentQuestionIndex].sampleTranslation;\n\n            appendMessage(`\u95ee\u9898: '${currentQuestion}' - '${translation}'`, 'bot');\n            appendMessage(`\u793a\u4f8b\u56de\u7b54: '${sampleAnswer}' - '${sampleTranslation}'`, 'bot');\n            addWhQuestionToBox(currentQuestion, translation, sampleAnswer, sampleTranslation);\n            sayText(currentQuestion, \"zh-CN\", function() { \/\/ Speak the question in Chinese\n                setTimeout(() => {\n                    sayText(currentQuestion, \"zh-CN\", function() { \/\/ Repeat the question in Chinese\n                        setTimeout(() => {\n                            if (isSpeechRecognitionSupported) {\n                                \/\/ Show replay button\n                                document.getElementById('replay-btn').style.display = 'block';\n                                \/\/ Prompt user to answer\n                                appendMessage(`\u8bf7\u7528\u4e2d\u6587\u56de\u7b54\u3002`, 'bot');\n                                sayText(\"\u8bf7\u7528\u4e2d\u6587\u56de\u7b54\u3002\", \"zh-CN\", function() {\n                                    listenUserResponse();\n                                });\n                            } else {\n                                \/\/ Show replay button\n                                document.getElementById('replay-btn').style.display = 'block';\n                                \/\/ Prompt user to type\n                                appendMessage(`\u8bf7\u5728\u4e0b\u65b9\u6587\u672c\u6846\u4e2d\u7528\u4e2d\u6587\u8f93\u5165\u60a8\u7684\u56de\u7b54\u3002`, 'bot');\n                                sayText(`\u8bf7\u5728\u4e0b\u65b9\u6587\u672c\u6846\u4e2d\u7528\u4e2d\u6587\u8f93\u5165\u60a8\u7684\u56de\u7b54\u3002`, \"zh-CN\");\n                                \/\/ Focus the text input\n                                document.getElementById('user-input').focus();\n                            }\n                        }, 500); \/\/ Small pause before prompt\n                    });\n                }, 500); \/\/ Small pause before second repetition\n            });\n        } else {\n            endLesson();\n        }\n    }\n\n    function listenUserResponse() {\n        recognition.start();\n\n        recognition.onresult = function(event) {\n            let userInput = event.results[0][0].transcript.trim();\n            appendMessage(userInput, 'user');\n\n            processUserResponse(userInput);\n        };\n\n        recognition.onspeechend = function() {\n            recognition.stop();\n        };\n\n        recognition.onerror = function(event) {\n            let errorMessage = '';\n            switch(event.error) {\n                case 'no-speech':\n                    errorMessage = '\u6ca1\u6709\u68c0\u6d4b\u5230\u8bed\u97f3\u3002\u8bf7\u518d\u8bd5\u4e00\u6b21\u6216\u5728\u6587\u672c\u6846\u4e2d\u8f93\u5165\u60a8\u7684\u56de\u7b54\u3002';\n                    break;\n                case 'audio-capture':\n                    errorMessage = '\u9ea6\u514b\u98ce\u8bbf\u95ee\u88ab\u62d2\u7edd\u3002\u8bf7\u68c0\u67e5\u60a8\u7684\u8bbe\u7f6e\u6216\u5728\u6587\u672c\u6846\u4e2d\u8f93\u5165\u60a8\u7684\u56de\u7b54\u3002';\n                    break;\n                case 'not-allowed':\n                    errorMessage = '\u9ea6\u514b\u98ce\u6743\u9650\u88ab\u62d2\u7edd\u3002';\n                    break;\n                default:\n                    errorMessage = '\u53d1\u751f\u9519\u8bef: ' + event.error;\n            }\n            appendMessage(errorMessage, 'bot');\n            sayText(errorMessage, 'zh-CN');\n        };\n    }\n\n    function processUserResponse(userInput, expectedAnswer = whQuestions[currentQuestionIndex].sampleAnswer) {\n        appendMessage(userInput, 'user');\n\n        if (stopKeywords.includes(userInput)) { \/\/ Removed toLowerCase since Chinese is case-sensitive\n            endLesson(true); \/\/ User requested to stop the lesson\n            return;\n        }\n\n        \/\/ Simple validation: check if user input contains keywords from expectedAnswer\n        const expectedKeywords = whQuestions[currentQuestionIndex].keywords;\n        let isCorrect = expectedKeywords.every(keyword => userInput.includes(keyword));\n\n        if (isCorrect) { \n            const positiveMessage = \"\u5f88\u597d\uff01\u60a8\u7684\u56de\u7b54\u6b63\u786e\u3002\";\n            appendMessage(positiveMessage, 'bot');\n            sayText(positiveMessage, 'zh-CN'); \/\/ Feedback in Chinese\n            score += 1;\n            updateProgress();\n            repeatAttempts = 0; \/\/ Reset the attempts counter\n            currentQuestionIndex++;\n            localStorage.setItem('currentQuestionIndex', currentQuestionIndex);\n            localStorage.setItem('score', score);\n            setTimeout(startWhQuestionLesson, 2000); \/\/ Move to next question after 2 seconds\n        } else {\n            repeatAttempts++;\n            if (repeatAttempts < 2) {\n                const retryMessage = \"\u4e0d\u6b63\u786e\u3002\u8bf7\u518d\u8bd5\u4e00\u6b21\u3002\";\n                appendMessage(retryMessage, 'bot');\n\n                \/\/ Speak the retry message\n                sayText(\"\u4e0d\u6b63\u786e\u3002\u8bf7\u518d\u8bd5\u4e00\u6b21\u3002\", 'zh-CN', function() {\n                    setTimeout(() => {\n                        if (isSpeechRecognitionSupported) {\n                            listenUserResponse();\n                        } else {\n                            \/\/ Focus the text input\n                            document.getElementById('user-input').focus();\n                        }\n                    }, 500); \/\/ Small pause before prompt\n                });\n            } else {\n                \/\/ **Modified Section Starts Here**\n                const correctAnswerMessage = `\u60a8\u5df2\u7ecf\u5c1d\u8bd5\u4e24\u6b21\u3002\u6b63\u786e\u7684\u56de\u7b54\u662f '${expectedAnswer}'\u3002\u6211\u4eec\u7ee7\u7eed\u4e0b\u4e00\u4e2a\u95ee\u9898\u5427\u3002`;\n                appendMessage(correctAnswerMessage, 'bot');\n\n                \/\/ Sequentially speak the messages\n                sayText(\"\u60a8\u5df2\u7ecf\u5c1d\u8bd5\u4e24\u6b21\u3002\u6b63\u786e\u7684\u56de\u7b54\u662f '\" + expectedAnswer + \"'.\", 'zh-CN', function() {\n                    sayText(expectedAnswer, 'zh-CN', function() { \/\/ Speak the answer in Chinese\n                        sayText(\"\u6211\u4eec\u7ee7\u7eed\u4e0b\u4e00\u4e2a\u95ee\u9898\u5427\u3002\", 'zh-CN', function() {\n                            \/\/ Proceed to next question after all speech has been completed\n                            repeatAttempts = 0; \/\/ Reset the attempts counter\n                            currentQuestionIndex++;\n                            localStorage.setItem('currentQuestionIndex', currentQuestionIndex);\n                            localStorage.setItem('score', score);\n                            setTimeout(startWhQuestionLesson, 2000); \/\/ Move to next question after 2 seconds\n                        });\n                    });\n                });\n                \/\/ **Modified Section Ends Here**\n            }\n        }\n    }\n\n    function addWhQuestionToBox(question, translation, sampleAnswer, sampleTranslation) {\n        const questionBox = document.getElementById('wh-question-box');\n        const questionElement = document.createElement('div');\n        questionElement.innerHTML = `<strong>\u95ee\u9898:<\/strong> '${question}'<br><strong>\u7ffb\u8bd1:<\/strong> '${translation}'<br><strong>\u793a\u4f8b\u56de\u7b54:<\/strong> '${sampleAnswer}' - '${sampleTranslation}'`;\n        questionBox.appendChild(questionElement);\n    }\n\n    function clearWhQuestionBox() {\n        const questionBox = document.getElementById('wh-question-box');\n        questionBox.innerHTML = '';\n    }\n\n    function endLesson(userStopped = false) {\n        let message;\n        if (userStopped) {\n            message = \"\u611f\u8c22\u60a8\u7684\u5b66\u4e60\uff01\u5e0c\u671b\u60a8\u559c\u6b22\u672c\u8bfe\u7a0b\u3002\";\n        } else {\n            message = `\u505a\u5f97\u597d\uff01\u60a8\u5b8c\u6210\u4e86\u6240\u670920\u4e2a\u95ee\u9898\uff0c\u5f97\u5206\u4e3a${score}\u5206\uff08\u6ee1\u5206${whQuestions.length}\u5206\uff09\u3002\u7ee7\u7eed\u52aa\u529b\uff01`;\n        }\n        appendMessage(message, \"bot\");\n        sayText(message, \"zh-CN\"); \/\/ End feedback in Chinese\n        \/\/ Hide replay button at the end\n        document.getElementById('replay-btn').style.display = 'none';\n        \/\/ Clear saved progress\n        localStorage.removeItem('currentQuestionIndex');\n        localStorage.removeItem('score');\n    }\n\n    function sayText(text, lang, callback) {\n        if (!speechSynthesisSupported) {\n            if (callback) callback();\n            return;\n        }\n        const utterance = new SpeechSynthesisUtterance(text);\n        utterance.lang = lang;\n        \/\/ Adjust rate and pitch for Mandarin Chinese\n        if (lang.startsWith('zh')) {\n            utterance.rate = 0.9;\n            utterance.pitch = 1.1;\n        } else {\n            utterance.rate = 1.0;\n            utterance.pitch = 1.0;\n        }\n        const voices = window.speechSynthesis.getVoices();\n        let selectedVoice = voices.find(voice => voice.lang === lang);\n        if (!selectedVoice) {\n            \/\/ Fallback to any voice that matches the language\n            selectedVoice = voices.find(voice => voice.lang.startsWith(lang));\n        }\n        if (selectedVoice) {\n            utterance.voice = selectedVoice;\n        }\n        utterance.onend = function() {\n            if (callback) callback();\n        };\n        window.speechSynthesis.speak(utterance);\n    }\n\n    function appendMessage(text, sender) {\n        const messageContainer = document.getElementById('chat-messages');\n        const messageElement = document.createElement('div');\n        messageElement.classList.add('message');\n        messageElement.classList.add(sender === 'bot' ? 'bot-message' : 'user-message');\n        messageElement.innerText = text;\n        messageContainer.appendChild(messageElement);\n        messageContainer.scrollTop = messageContainer.scrollHeight;\n    }\n\n    \/\/ Function to display in-page notifications\n    function displayNotification(message) {\n        \/\/ Create a notification div if it doesn't exist\n        let notification = document.getElementById('notification');\n        if (!notification) {\n            notification = document.createElement('div');\n            notification.id = 'notification';\n            notification.style.display = 'none';\n            notification.style.padding = '10px';\n            notification.style.backgroundColor = '#ffdddd';\n            notification.style.color = '#d8000c';\n            notification.style.margin = '10px';\n            document.body.insertBefore(notification, document.body.firstChild);\n        }\n        notification.innerText = message;\n        notification.style.display = 'block';\n    }\n\n    \/\/ Function to update progress bar\n    function updateProgress() {\n        const progressBar = document.getElementById('progress-bar');\n        const progressPercentage = (currentQuestionIndex \/ whQuestions.length) * 100;\n        progressBar.style.width = `${progressPercentage}%`;\n    }\n    <\/script>\n<\/body>\n<\/html>\n\n","protected":false},"excerpt":{"rendered":"<p>Chinese WH-Questions &#8211; Family Vocabulary Sentences Yes\/No Questions Like Questions WH Questions Check the questions and sample answers in this box Chinese WH-Questions &#8211; Family Submit Replay Start Lesson Stop<\/p>\n","protected":false},"author":1,"featured_media":1344,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[43,44,34],"tags":[],"class_list":["post-1743","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-chinese","category-family-chinese","category-robots"],"featured_image_src":"https:\/\/phamho.com\/book\/wp-content\/uploads\/2024\/06\/iPad-1024x585.webp","blog_images":{"medium":"https:\/\/phamho.com\/book\/wp-content\/uploads\/2024\/06\/iPad-300x171.webp","large":"https:\/\/phamho.com\/book\/wp-content\/uploads\/2024\/06\/iPad-1024x585.webp"},"ams_acf":[],"_links":{"self":[{"href":"https:\/\/phamho.com\/book\/wp-json\/wp\/v2\/posts\/1743","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/phamho.com\/book\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/phamho.com\/book\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/phamho.com\/book\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/phamho.com\/book\/wp-json\/wp\/v2\/comments?post=1743"}],"version-history":[{"count":2,"href":"https:\/\/phamho.com\/book\/wp-json\/wp\/v2\/posts\/1743\/revisions"}],"predecessor-version":[{"id":1745,"href":"https:\/\/phamho.com\/book\/wp-json\/wp\/v2\/posts\/1743\/revisions\/1745"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/phamho.com\/book\/wp-json\/wp\/v2\/media\/1344"}],"wp:attachment":[{"href":"https:\/\/phamho.com\/book\/wp-json\/wp\/v2\/media?parent=1743"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/phamho.com\/book\/wp-json\/wp\/v2\/categories?post=1743"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/phamho.com\/book\/wp-json\/wp\/v2\/tags?post=1743"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}