{"id":1607,"date":"2024-09-16T12:04:08","date_gmt":"2024-09-16T12:04:08","guid":{"rendered":"https:\/\/phamho.com\/book\/?p=1607"},"modified":"2024-10-10T03:20:12","modified_gmt":"2024-10-10T03:20:12","slug":"english-playing-sports","status":"publish","type":"post","link":"https:\/\/phamho.com\/book\/english-playing-sports\/","title":{"rendered":"English Sentences &#8211; Sports"},"content":{"rendered":"\n<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n    <meta charset=\"UTF-8\">\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n    <title>English Sentences &#8211; Sports<\/title>\n    <style>\n        \/* Reset and Base Styles *\/\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\n        \/* Menu Styles *\/\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        .menu a:focus {\n            text-decoration: underline;\n            outline: 2px dashed #fff;\n            outline-offset: 4px;\n        }\n\n        \/* Container Styles *\/\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        .sentence-text {\n            margin: 10px 0;\n            font-weight: bold;\n            color: #333;\n            font-size: 16px;\n        }\n        .word-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\n        \/* Chat Container Styles *\/\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            display: flex;\n            flex-direction: column;\n            height: 600px;\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        .chat-messages {\n            padding: 10px;\n            overflow-y: auto;\n            flex: 1;\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\n        \/* Chat Input Styles *\/\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 {\n            background-color: #17c686;\n            color: #fff;\n            font-weight: bold;\n            border: none;\n            border-radius: 5px;\n            padding: 12px 20px; \/* Increased padding for better touch targets *\/\n            cursor: pointer;\n            transition: background-color 0.3s;\n            flex: 1;\n            margin: 0 5px;\n            max-width: 150px;\n            font-size: 16px; \/* Slightly larger font for readability *\/\n        }\n        .stop-button {\n            background-color: #c86722;\n        }\n        .send-button:hover,\n        .stop-button:hover,\n        .send-button:focus,\n        .stop-button:focus {\n            background-color: #45a049;\n            outline: none;\n        }\n\n        \/* Loader Styles *\/\n        .loader {\n            border: 4px solid #f3f3f3;\n            border-top: 4px solid #2196f3;\n            border-radius: 50%;\n            width: 20px;\n            height: 20px;\n            animation: spin 2s linear infinite;\n            display: inline-block;\n            margin-left: 10px;\n        }\n\n        @keyframes spin {\n            0% { transform: rotate(0deg); }\n            100% { transform: rotate(360deg); }\n        }\n\n        \/* Responsive Design Adjustments *\/\n        @media (max-width: 600px) {\n            .menu a {\n                margin: 0 5px;\n                font-size: 12px;\n            }\n            .sentence-text {\n                font-size: 14px;\n            }\n            .word-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 {\n                padding: 10px 12px;\n                font-size: 14px;\n                max-width: 120px;\n            }\n        }\n        @media (max-width: 400px) {\n            .menu a {\n                margin: 0 3px;\n                font-size: 11px;\n            }\n            .sentence-text {\n                font-size: 13px;\n            }\n            .word-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 {\n                padding: 8px 10px;\n                font-size: 12px;\n                max-width: 100px;\n            }\n        }\n\n        \/* Android Specific Adjustments *\/\n        @media only screen and (max-device-width: 480px) and (-webkit-min-device-pixel-ratio: 2) {\n            \/* Adjust font sizes and button sizes for high-density screens *\/\n            .chat-header h2 {\n                font-size: 18px;\n            }\n            .send-button, .stop-button {\n                padding: 14px 20px;\n                font-size: 16px;\n            }\n            .message {\n                font-size: 14px;\n            }\n            .word-box {\n                font-size: 16px;\n            }\n        }\n    <\/style>\n<\/head>\n<body>\n    <div class=\"menu\">\n      <a href=\"https:\/\/phamho.com\/book\/2024\/09\/15\/learn-vocabulary-sports\/\">Vocabulary<\/a>\n      <a href=\"https:\/\/phamho.com\/book\/2024\/09\/16\/english-sports-examples\/\">Examples<\/a>\n      <a href=\"https:\/\/phamho.com\/book\/2024\/09\/16\/english-sports-questions\/\">Questions<\/a>\n      <a href=\"https:\/\/phamho.com\/book\/2024\/09\/16\/english-sports-yes-no-questions\/\">Yes\/No Questions<\/a>\n      <a href=\"https:\/\/phamho.com\/book\/2024\/09\/16\/english-sports-wh-questions\/\">WH Questions<\/a>\n      <a href=\"https:\/\/phamho.com\/book\/2024\/09\/15\/interaction-sports\/\">Interaction<\/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\/Robotic.webp\" alt=\"Lesson Robot\">\n            <div class=\"sentence-text\">Look at the box below<\/div>\n            <div id=\"word-box\" class=\"word-box\">\n                <!-- Learned sentences will be displayed here -->\n            <\/div>\n        <\/div>\n        <div class=\"chat-container\">\n            <div class=\"chat-header\">\n                <h2>English Sentences &#8211; Sports<\/h2>\n            <\/div>\n            <div class=\"chat-messages\" id=\"chat-messages\">\n                <!-- Messages will appear here -->\n            <\/div>\n            <div class=\"chat-input\">\n                <button id=\"start-btn\" class=\"send-button\" aria-label=\"Start Lesson\">Start Lesson<\/button>\n                <button id=\"stop-btn\" class=\"stop-button\" aria-label=\"Stop Lesson\">Stop<\/button>\n            <\/div>\n        <\/div>\n    <\/div>\n\n    <script>\n    const sentences = [\n        { sentence: \"I play soccer.\", translation: \"T\u00f4i ch\u01a1i b\u00f3ng \u0111\u00e1.\" },\n        { sentence: \"I practice basketball.\", translation: \"T\u00f4i t\u1eadp b\u00f3ng r\u1ed5.\" },\n        { sentence: \"I swim in the pool.\", translation: \"T\u00f4i b\u01a1i trong h\u1ed3.\" },\n        { sentence: \"I run in the park.\", translation: \"T\u00f4i ch\u1ea1y b\u1ed9 trong c\u00f4ng vi\u00ean.\" },\n        { sentence: \"I go cycling.\", translation: \"T\u00f4i \u0111i \u0111\u1ea1p xe.\" },\n        { sentence: \"I play tennis.\", translation: \"T\u00f4i ch\u01a1i qu\u1ea7n v\u1ee3t.\" },\n        { sentence: \"I practice martial arts.\", translation: \"T\u00f4i t\u1eadp v\u00f5.\" },\n        { sentence: \"I do yoga.\", translation: \"T\u00f4i t\u1eadp yoga.\" },\n        { sentence: \"I climb mountains.\", translation: \"T\u00f4i leo n\u00fai.\" },\n        { sentence: \"I go hiking.\", translation: \"T\u00f4i \u0111i b\u1ed9 \u0111\u01b0\u1eddng d\u00e0i.\" }\n    ];\n\n    let currentSentenceIndex = 0;\n    let repeatAttempts = 0;\n    let recognition;\n\n    const stopKeywords = [\"goodbye\", \"good bye\", \"bye\", \"bye bye\", \"stop\", \"end\", \"quit\", \"exit\"];\n\n    const speechSynthesisSupported = 'speechSynthesis' in window;\n    const speechRecognitionSupported = window.SpeechRecognition || window.webkitSpeechRecognition;\n\n    if (speechRecognitionSupported) {\n        recognition = new (window.SpeechRecognition || window.webkitSpeechRecognition)();\n        recognition.lang = 'en-US';\n        recognition.interimResults = false;\n        recognition.maxAlternatives = 1;\n    }\n\n    let voices = [];\n    function loadVoices() {\n        voices = window.speechSynthesis.getVoices();\n        if (voices.length === 0) {\n            \/\/ Some browsers load voices asynchronously\n            window.speechSynthesis.onvoiceschanged = () => {\n                voices = window.speechSynthesis.getVoices();\n                console.log(\"Voices loaded:\", voices);\n                \/\/ Optionally, you can trigger a re-greet here if needed\n            };\n        } else {\n            console.log(\"Voices loaded:\", voices);\n        }\n    }\n\n    loadVoices();\n\n    window.onload = function() {\n        if (speechSynthesisSupported) {\n            \/\/ Delay greeting to ensure voices are loaded\n            setTimeout(() => greetUser(), 500); \n        } else {\n            appendMessage(\"Sorry, your browser does not support speech synthesis.\", \"bot\");\n        }\n\n        if (!speechRecognitionSupported) {\n            appendMessage(\"Sorry, your browser does not support speech recognition.\", \"bot\");\n        }\n    };\n\n    function greetUser() {\n        const greeting = \"Welcome! In this lesson, you will learn 10 simple sentences about playing sports in English. I will say each sentence twice, and then you will repeat. Are you ready? Click Start Lesson to begin.\";\n        appendMessage(greeting, 'bot');\n        sayText(greeting, 'en-US');\n    }\n\n    document.getElementById('start-btn').onclick = function() {\n        if (!speechSynthesisSupported) {\n            appendMessage(\"Speech synthesis is not supported in your browser.\", \"bot\");\n            return;\n        }\n        if (speechRecognitionSupported) {\n            currentSentenceIndex = 0;\n            repeatAttempts = 0;\n            startLesson();\n        } else {\n            appendMessage(\"Speech recognition is not supported in your browser.\", \"bot\");\n        }\n    };\n\n    document.getElementById('stop-btn').onclick = function() {\n        endLesson(true); \/\/ Stop the lesson when \"Stop\" button is clicked\n    };\n\n    function startLesson() {\n        if (currentSentenceIndex < sentences.length) {\n            const sentence = sentences[currentSentenceIndex].sentence;\n            const translation = sentences[currentSentenceIndex].translation;\n\n            appendMessage(`'${sentence}' - '${translation}'`, 'bot');\n            addSentenceToBox(sentence, translation);\n            sayText(sentence, \"en-US\");\n            setTimeout(() => sayText(sentence, \"en-US\"), 1500); \/\/ Say the sentence twice\n\n            setTimeout(() => {\n                const repeatMessage = `Now repeat after me: '${sentence}'`;\n                appendMessage(repeatMessage, 'bot');\n                sayText(repeatMessage, \"en-US\");\n                listenUserResponse(sentence);\n            }, 3000);\n        } else {\n            endLesson();\n        }\n    }\n\n    function listenUserResponse(expectedSentence) {\n        recognition = new (window.SpeechRecognition || window.webkitSpeechRecognition)();\n        recognition.lang = 'en-US';\n        recognition.interimResults = false;\n        recognition.maxAlternatives = 1;\n\n        recognition.start();\n\n        recognition.onresult = function(event) {\n            let userInput = event.results[0][0].transcript.trim();\n            appendMessage(userInput, 'user');\n\n            if (stopKeywords.includes(userInput.toLowerCase())) {\n                endLesson(true); \/\/ User requested to stop the lesson\n                return;\n            }\n\n            const normalizedInput = userInput.toLowerCase().replace(\/[\\s?!.,']+\/g, '');\n            const normalizedExpected = expectedSentence.toLowerCase().replace(\/[\\s?!.,']+\/g, '');\n\n            if (normalizedInput === normalizedExpected) {\n                const positiveMessage = \"Perfect! Let's continue.\";\n                appendMessage(positiveMessage, 'bot');\n                sayText(positiveMessage, 'en-US'); \/\/ Feedback in English\n                repeatAttempts = 0; \/\/ Reset the attempts counter\n                currentSentenceIndex++;\n                setTimeout(startLesson, 2000); \/\/ Move to next sentence after 2 seconds\n            } else {\n                repeatAttempts++;\n                if (repeatAttempts < 2) {\n                    const correctionMessage = `That's not correct. Listen again: '${expectedSentence}'. Can you say it again?`;\n                    appendMessage(correctionMessage, 'bot');\n                    sayText(\"That's not correct. Listen again:\", 'en-US'); \/\/ Feedback in English\n                    sayText(expectedSentence, 'en-US'); \/\/ Say the sentence in English\n                    setTimeout(() => {\n                        sayText(\"Can you say it again?\", 'en-US'); \/\/ Prompt to repeat in English\n                        listenUserResponse(expectedSentence);\n                    }, 3000);\n                } else {\n                    const nextSentenceMessage = `You've tried twice. The correct sentence is '${expectedSentence}'. Let's move on.`;\n                    appendMessage(nextSentenceMessage, 'bot');\n                    sayText(nextSentenceMessage, 'en-US'); \/\/ Feedback in English\n                    repeatAttempts = 0; \/\/ Reset the attempts counter\n                    currentSentenceIndex++;\n                    setTimeout(startLesson, 2000);\n                }\n            }\n        };\n\n        recognition.onspeechend = function() {\n            recognition.stop();\n        };\n\n        recognition.onerror = function(event) {\n            appendMessage('Error: ' + event.error, 'bot');\n            repeatAttempts++;\n            if (repeatAttempts < 2) {\n                const retryMessage = `I didn't catch that. Please repeat: '${expectedSentence}'`;\n                appendMessage(retryMessage, 'bot');\n                sayText(\"I didn't catch that. Please repeat:\", 'en-US');\n                sayText(expectedSentence, 'en-US');\n                listenUserResponse(expectedSentence);\n            } else {\n                const nextSentenceMessage = `You've tried twice. The correct sentence is '${expectedSentence}'. Let's move on.`;\n                appendMessage(nextSentenceMessage, 'bot');\n                sayText(nextSentenceMessage, 'en-US');\n                repeatAttempts = 0;\n                currentSentenceIndex++;\n                setTimeout(startLesson, 2000);\n            }\n        };\n    }\n\n    function addSentenceToBox(sentence, translation) {\n        const wordBox = document.getElementById('word-box');\n        const sentenceElement = document.createElement('div');\n        sentenceElement.innerText = `'${sentence}' - '${translation}'`;\n        wordBox.appendChild(sentenceElement);\n    }\n\n    function endLesson(userStopped = false) {\n        let message;\n        if (userStopped) {\n            message = \"Thank you for learning today! I hope you enjoyed the lesson.\";\n        } else {\n            message = \"Well done! You've learned 10 sentences about playing sports. Keep practicing!\";\n        }\n        appendMessage(message, \"bot\");\n        sayText(message, \"en-US\"); \/\/ End feedback in English\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        utterance.rate = 1.0;\n        utterance.pitch = 1.0;\n\n        if (voices.length === 0) {\n            \/\/ If voices are not loaded yet, wait for them\n            window.speechSynthesis.onvoiceschanged = () => {\n                voices = window.speechSynthesis.getVoices();\n                selectVoice(utterance, lang);\n                utterance.onend = function() {\n                    if (callback) callback();\n                };\n                window.speechSynthesis.speak(utterance);\n            };\n        } else {\n            selectVoice(utterance, lang);\n            utterance.onend = function() {\n                if (callback) callback();\n            };\n            window.speechSynthesis.speak(utterance);\n        }\n    }\n\n    function selectVoice(utterance, lang) {\n        \/\/ Prioritize specific high-quality voices\n        const preferredVoiceNames = [\n            'Google US English',\n            'Google UK English Female',\n            'Google UK English Male',\n            'Google US English Female',\n            'Google US English Male'\n        ];\n\n        \/\/ Try to find a preferred voice first\n        let selectedVoice = voices.find(voice => preferredVoiceNames.includes(voice.name));\n\n        \/\/ If no preferred voice is found, fallback to any English voice\n        if (!selectedVoice) {\n            selectedVoice = voices.find(voice => voice.lang === lang && voice.name.toLowerCase().includes('english')) ||\n                            voices.find(voice => voice.lang.startsWith('en'));\n        }\n\n        if (selectedVoice) {\n            utterance.voice = selectedVoice;\n            console.log(`Selected voice: ${selectedVoice.name}`);\n        } else {\n            console.warn(\"No suitable English voice found. Using default voice.\");\n        }\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    <\/script>\n<\/body>\n<\/html>\n","protected":false},"excerpt":{"rendered":"<p>English Sentences &#8211; Sports Vocabulary Examples Questions Yes\/No Questions WH Questions Interaction Look at the box below English Sentences &#8211; Sports Start Lesson Stop<\/p>\n","protected":false},"author":1,"featured_media":1608,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[28,35,47,34,27,39],"tags":[],"class_list":["post-1607","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-adults","category-b1","category-pet","category-robots","category-speaking","category-sports"],"featured_image_src":"https:\/\/phamho.com\/book\/wp-content\/uploads\/2024\/09\/DALL\u00b7E-2024-09-15-18.17.31-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","blog_images":{"medium":"https:\/\/phamho.com\/book\/wp-content\/uploads\/2024\/09\/DALL\u00b7E-2024-09-15-18.17.31-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-300x300.webp","large":"https:\/\/phamho.com\/book\/wp-content\/uploads\/2024\/09\/DALL\u00b7E-2024-09-15-18.17.31-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"},"ams_acf":[],"_links":{"self":[{"href":"https:\/\/phamho.com\/book\/wp-json\/wp\/v2\/posts\/1607","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=1607"}],"version-history":[{"count":7,"href":"https:\/\/phamho.com\/book\/wp-json\/wp\/v2\/posts\/1607\/revisions"}],"predecessor-version":[{"id":1695,"href":"https:\/\/phamho.com\/book\/wp-json\/wp\/v2\/posts\/1607\/revisions\/1695"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/phamho.com\/book\/wp-json\/wp\/v2\/media\/1608"}],"wp:attachment":[{"href":"https:\/\/phamho.com\/book\/wp-json\/wp\/v2\/media?parent=1607"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/phamho.com\/book\/wp-json\/wp\/v2\/categories?post=1607"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/phamho.com\/book\/wp-json\/wp\/v2\/tags?post=1607"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}