{"id":1543,"date":"2024-09-16T02:31:10","date_gmt":"2024-09-16T02:31:10","guid":{"rendered":"https:\/\/phamho.com\/book\/?p=1543"},"modified":"2024-09-16T04:05:38","modified_gmt":"2024-09-16T04:05:38","slug":"spanish-vocabulary-school","status":"publish","type":"post","link":"https:\/\/phamho.com\/book\/spanish-vocabulary-school\/","title":{"rendered":"Spanish Vocabulary &#8211; School"},"content":{"rendered":"\n<!DOCTYPE html>\n<html lang=\"es\">\n<head>\n    <meta charset=\"UTF-8\">\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n    <title>Aprender Vocabulario &#8211; Escuela<\/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            justify-content: center;\n            align-items: center;\n            height: 100vh;\n            flex-direction: column;\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            margin-bottom: 20px;\n        }\n        .menu a {\n            color: #fff;\n            text-decoration: none;\n            margin: 0 15px;\n            font-weight: bold;\n        }\n        .menu a:hover {\n            text-decoration: underline;\n        }\n        .container {\n            display: flex;\n            align-items: flex-start;\n        }\n        .image-container {\n            margin-right: 20px;\n            text-align: center;\n        }\n        .image-container img {\n            max-width: 300px;\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        }\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        .chat-container {\n            max-width: 400px;\n            background-color: #026c96;\n            border-radius: 20px;\n            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);\n            overflow: hidden;\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-messages {\n            padding: 10px;\n            overflow-y: auto;\n            max-height: 300px;\n        }\n        .message {\n            margin-bottom: 10px;\n            padding: 10px;\n            border-radius: 5px;\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: #080900;\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: space-between;\n        }\n        .send-button {\n            background-color: #17c686;\n            color: #fff;\n            font-weight: bold;\n            border: none;\n            border-radius: 5px;\n            padding: 8px 15px;\n            cursor: pointer;\n            transition: background-color 0.3s;\n        }\n        .stop-button {\n            background-color: #c86722;\n            color: #fff;\n            font-weight: bold;\n            border: none;\n            border-radius: 5px;\n            padding: 8px 15px;\n            cursor: pointer;\n            transition: background-color 0.3s;\n        }\n    <\/style>\n<\/head>\n<body>\n    <div class=\"menu\">\n      <a href=\"https:\/\/phamho.com\/book\/2024\/09\/16\/spanish-vocabulary-school\/\">School<\/a>\n      <a href=\"https:\/\/phamho.com\/book\/2024\/09\/16\/spanish-vocabulary\/\">Family<\/a>\n      <a href=\"https:\/\/phamho.com\/book\/2024\/09\/16\/spanish-vocabulary-home\/\">Home<\/a>\n      <a href=\"https:\/\/phamho.com\/book\/2024\/09\/16\/spanish-vocabulary-travel\/\">Travel<\/a>\n      <a href=\"https:\/\/phamho.com\/book\/2024\/09\/16\/spanish-vocabulary-body\/\">Body<\/a>\n      <a href=\"https:\/\/phamho.com\/book\/2024\/09\/16\/spanish-vocabulary-sports\/\">Sports<\/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\/08\/163abc3a-5b10-4eb5-9562-b9ad98ada23d.webp\" alt=\"Lecci\u00f3n Robot\">\n            <div class=\"sentence-text\">Look at the box below<\/div>\n            <div id=\"word-box\" class=\"word-box\">\n                <!-- Learned school-related words and phrases will be displayed here -->\n            <\/div>\n        <\/div>\n        <div class=\"chat-container\">\n            <div class=\"chat-header\">\n                <h2>Aprender Vocabulario &#8211; Escuela<\/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\">Start Lesson<\/button>\n                <button id=\"stop-btn\" class=\"stop-button\">Stop<\/button>\n            <\/div>\n        <\/div>\n    <\/div>\n\n    <script>\n    const vocabulary = [\n        { word: \"la escuela\", translation: \"the school\" },\n        { word: \"el maestro\", translation: \"the teacher (male)\" },\n        { word: \"la maestra\", translation: \"the teacher (female)\" },\n        { word: \"la clase\", translation: \"the class\" },\n        { word: \"el libro\", translation: \"the book\" },\n        { word: \"el cuaderno\", translation: \"the notebook\" },\n        { word: \"la tarea\", translation: \"the homework\" },\n        { word: \"el estudiante\", translation: \"the student (male)\" },\n        { word: \"la estudiante\", translation: \"the student (female)\" },\n        { word: \"la lecci\u00f3n\", translation: \"the lesson\" },\n        { word: \"la pizarra\", translation: \"the board\" },\n        { word: \"la pluma\", translation: \"the pen\" },\n        { word: \"el l\u00e1piz\", translation: \"the pencil\" },\n        { word: \"la mochila\", translation: \"the backpack\" },\n        { word: \"la computadora\", translation: \"the computer\" },\n        { word: \"hacer la tarea\", translation: \"to do homework\" },\n        { word: \"estudiar para el examen\", translation: \"to study for the exam\" },\n        { word: \"prestar atenci\u00f3n\", translation: \"to pay attention\" },\n        { word: \"ir a la escuela\", translation: \"to go to school\" },\n        { word: \"hacer preguntas\", translation: \"to ask questions\" }\n    ];\n\n    let currentWordIndex = 0;\n    let repeatAttempts = 0;\n    let recognition;\n\n    const stopKeywords = [\"adi\u00f3s\", \"goodbye\", \"good bye\",\"bye\", \"bye bye\", \"byebye\", \"hasta luego\", \"chao\"];\n\n    window.onload = function() {\n        window.speechSynthesis.onvoiceschanged = () => {\n            greetUser();\n        };\n\n        if (window.speechSynthesis.getVoices().length !== 0) {\n            greetUser();\n        }\n    };\n\n    function greetUser() {\n        const greeting = \"Welcome! In this lesson, you will learn 20 words and phrases about school in Spanish. I will say each word or phrase twice, and then you will repeat. Are you ready? Click Start Lesson to begin.\";\n        appendMessage(greeting, 'bot');\n        sayText(greeting, 'en');\n    }\n\n    document.getElementById('start-btn').onclick = function() {\n        currentWordIndex = 0;\n        repeatAttempts = 0;\n        startVocabularyLesson();\n    };\n\n    document.getElementById('stop-btn').onclick = function() {\n        endLesson(true); \/\/ Stop the lesson when \"Stop Lesson\" button is clicked\n    };\n\n    function startVocabularyLesson() {\n        if (currentWordIndex < vocabulary.length) {\n            const word = vocabulary[currentWordIndex].word;\n            const translation = vocabulary[currentWordIndex].translation;\n\n            appendMessage(`'${word}' - '${translation}'`, 'bot');\n            addWordToBox(word, translation);\n            sayText(word, \"es\");\n            setTimeout(() => sayText(word, \"es\"), 1500); \/\/ Say the word twice\n\n            setTimeout(() => {\n                const repeatMessage = `Ahora repite despu\u00e9s de m\u00ed: '${word}'`;\n                appendMessage(repeatMessage, 'bot');\n                sayText(repeatMessage, \"es\");\n                listenUserResponse(word);\n            }, 3000);\n        } else {\n            endLesson();\n        }\n    }\n\n    function listenUserResponse(expectedWord) {\n        recognition = new (window.SpeechRecognition || window.webkitSpeechRecognition)();\n        recognition.lang = 'es-ES';\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().toLowerCase();\n            appendMessage(userInput, 'user');\n\n            if (stopKeywords.includes(userInput)) {\n                endLesson(true); \/\/ User requested to stop the lesson\n                return;\n            }\n\n            if (userInput === expectedWord.toLowerCase()) {\n                const positiveMessage = \"Great! You are correct.\";\n                appendMessage(positiveMessage, 'bot');\n                sayText(positiveMessage, 'en'); \/\/ Feedback in English\n                repeatAttempts = 0; \/\/ Reset the attempts counter\n                currentWordIndex++;\n                setTimeout(startVocabularyLesson, 2000); \/\/ Move to next word after 2 seconds\n            } else {\n                repeatAttempts++;\n                if (repeatAttempts < 2) {\n                    const correctionMessage = `That's not correct. Listen again: '${expectedWord}'. Now repeat after me.`;\n                    appendMessage(correctionMessage, 'bot');\n                    sayText(correctionMessage, 'en');  \/\/ Feedback in English\n                    sayText(expectedWord, \"es\");\n                    setTimeout(() => listenUserResponse(expectedWord), 3000); \/\/ Repeat the word\n                } else {\n                    const nextWordMessage = `You've tried twice. The correct word is '${expectedWord}'. Let's move on to the next word.`;\n                    appendMessage(nextWordMessage, 'bot');\n                    sayText(nextWordMessage, 'en'); \/\/ Feedback in English\n                    repeatAttempts = 0; \/\/ Reset the attempts counter\n                    currentWordIndex++;\n                    setTimeout(startVocabularyLesson, 2000); \/\/ Move to next word after 2 seconds\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        };\n    }\n\n    function addWordToBox(word, translation) {\n        const wordBox = document.getElementById('word-box');\n        const wordElement = document.createElement('div');\n        wordElement.innerText = `'${word}' - '${translation}'`;\n        wordBox.appendChild(wordElement);\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 20 words and phrases related to school. Keep practicing!\";\n        }\n        appendMessage(message, \"bot\");\n        sayText(message, \"en\"); \/\/ End feedback in English\n    }\n\n    function sayText(text, lang) {\n        const utterance = new SpeechSynthesisUtterance(text);\n        utterance.lang = lang;\n        const voices = window.speechSynthesis.getVoices();\n        let selectedVoice = voices.find(voice => voice.lang === lang);\n        if (selectedVoice) {\n            utterance.voice = selectedVoice;\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.innerHTML = text;\n        messageContainer.appendChild(messageElement);\n        messageContainer.scrollTop = messageContainer.scrollHeight;\n    }\n    <\/script>\n<\/body>\n<\/html>\n","protected":false},"excerpt":{"rendered":"<p>Aprender Vocabulario &#8211; Escuela School Family Home Travel Body Sports Look at the box below Aprender Vocabulario &#8211; Escuela Start Lesson Stop<\/p>\n","protected":false},"author":1,"featured_media":1467,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[34,33,36],"tags":[],"class_list":["post-1543","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-robots","category-spanish","category-spanish-vocabulary"],"featured_image_src":"https:\/\/phamho.com\/book\/wp-content\/uploads\/2024\/09\/1cc8ad33-a235-4146-be1b-eba2698cfdc0.webp","blog_images":{"medium":"https:\/\/phamho.com\/book\/wp-content\/uploads\/2024\/09\/1cc8ad33-a235-4146-be1b-eba2698cfdc0-300x300.webp","large":"https:\/\/phamho.com\/book\/wp-content\/uploads\/2024\/09\/1cc8ad33-a235-4146-be1b-eba2698cfdc0.webp"},"ams_acf":[],"_links":{"self":[{"href":"https:\/\/phamho.com\/book\/wp-json\/wp\/v2\/posts\/1543","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=1543"}],"version-history":[{"count":5,"href":"https:\/\/phamho.com\/book\/wp-json\/wp\/v2\/posts\/1543\/revisions"}],"predecessor-version":[{"id":1571,"href":"https:\/\/phamho.com\/book\/wp-json\/wp\/v2\/posts\/1543\/revisions\/1571"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/phamho.com\/book\/wp-json\/wp\/v2\/media\/1467"}],"wp:attachment":[{"href":"https:\/\/phamho.com\/book\/wp-json\/wp\/v2\/media?parent=1543"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/phamho.com\/book\/wp-json\/wp\/v2\/categories?post=1543"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/phamho.com\/book\/wp-json\/wp\/v2\/tags?post=1543"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}