diff --git a/AI_Language_Learning_Assistant/AI-Language-Learning-Assistant.ipynb b/AI_Language_Learning_Assistant/AI-Language-Learning-Assistant.ipynb new file mode 100644 index 0000000000..96b42204ca --- /dev/null +++ b/AI_Language_Learning_Assistant/AI-Language-Learning-Assistant.ipynb @@ -0,0 +1,915 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "nzsvi_z__zl6", + "outputId": "c86dbd53-c4b0-423d-b0c0-93c33e739123" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Collecting SpeechRecognition\n", + " Downloading SpeechRecognition-3.10.4-py2.py3-none-any.whl.metadata (28 kB)\n", + "Requirement already satisfied: requests>=2.26.0 in /usr/local/lib/python3.10/dist-packages (from SpeechRecognition) (2.32.3)\n", + "Requirement already satisfied: typing-extensions in /usr/local/lib/python3.10/dist-packages (from SpeechRecognition) (4.12.2)\n", + "Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.10/dist-packages (from requests>=2.26.0->SpeechRecognition) (3.3.2)\n", + "Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.10/dist-packages (from requests>=2.26.0->SpeechRecognition) (3.7)\n", + "Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.10/dist-packages (from requests>=2.26.0->SpeechRecognition) (2.0.7)\n", + "Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.10/dist-packages (from requests>=2.26.0->SpeechRecognition) (2024.7.4)\n", + "Downloading SpeechRecognition-3.10.4-py2.py3-none-any.whl (32.8 MB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m32.8/32.8 MB\u001b[0m \u001b[31m49.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hInstalling collected packages: SpeechRecognition\n", + "Successfully installed SpeechRecognition-3.10.4\n" + ] + } + ], + "source": [ + "!pip install SpeechRecognition\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "dwX6C9DQFBRs" + }, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "id": "aLj8l9WI_-vB" + }, + "outputs": [], + "source": [ + "import random\n", + "import speech_recognition as sr" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "id": "lzUjKQyaAAeN" + }, + "outputs": [], + "source": [ + "# Vocabulary dictionary containing common words and their definitions.\n", + "vocabulary = {\n", + " 'apple': 'a fruit',\n", + " 'dog': 'an animal that barks',\n", + " 'cat': 'a small domesticated carnivorous mammal',\n", + " 'book': 'a written or printed work consisting of pages glued or sewn together along one side',\n", + " 'sun': 'the star around which the earth orbits',\n", + " 'moon': 'the natural satellite of the earth',\n", + " 'tree': 'a woody perennial plant',\n", + " 'ocean': 'a large body of salt water',\n", + " 'computer': 'an electronic device for storing and processing data',\n", + " 'music': 'vocal or instrumental sounds combined to produce beauty of form',\n", + " 'happy': 'feeling or showing pleasure or contentment',\n", + " 'sad': 'feeling or showing sorrow',\n", + " 'water': 'a colorless, transparent, odorless liquid',\n", + " 'sky': 'the region of the atmosphere above the earth',\n", + " 'mountain': 'a large natural elevation of the earth\\'s surface',\n", + " 'friend': 'a person whom one knows and with whom one has a bond of mutual affection',\n", + " 'love': 'an intense feeling of deep affection',\n", + " 'time': 'the indefinite continued progress of existence',\n", + " 'work': 'activity involving mental or physical effort done to achieve a purpose',\n", + " 'study': 'the devotion of time and attention to acquiring knowledge',\n", + " 'write': 'mark (letters, words, or other symbols) on a surface',\n", + " 'learn': 'gain or acquire knowledge of or skill in (something) by study, experience, or being taught',\n", + " 'laugh': 'make the spontaneous sounds and movements of the face and body that are the instinctive expressions of lively amusement',\n", + " 'run': 'move at a speed faster than a walk',\n", + " 'eat': 'put (food) into the mouth and chew and swallow it',\n", + " 'drink': 'take (a liquid) into the mouth and swallow',\n", + " 'jump': 'push oneself off a surface and into the air by using the muscles in one\\'s legs and feet',\n", + " 'sleep': 'be in a state of rest in which the eyes are closed',\n", + " 'happy': 'feeling or showing pleasure or contentment',\n", + " 'angry': 'having a strong feeling of or showing annoyance, displeasure, or hostility',\n", + " 'beautiful': 'pleasing the senses or mind aesthetically',\n", + " 'big': 'of considerable size or extent',\n", + " 'small': 'of a size that is less than normal or usual',\n", + " 'fast': 'moving or capable of moving at high speed',\n", + " 'slow': 'moving or operating at a low speed',\n", + " 'hot': 'having a high degree of heat or a high temperature',\n", + " 'cold': 'of or at a low or relatively low temperature',\n", + " 'old': 'having lived for a long time',\n", + " 'new': 'produced, introduced, or discovered recently or now for the first time',\n", + " 'happy': 'feeling or showing pleasure or contentment',\n", + " 'sad': 'feeling or showing sorrow',\n", + " 'flower': 'the seed-bearing part of a plant, consisting of reproductive organs',\n", + " 'house': 'a building for human habitation',\n", + " 'car': 'a road vehicle, typically with four wheels, powered by an internal combustion engine',\n", + " 'bicycle': 'a vehicle with two wheels, powered by pedals',\n", + " 'school': 'an institution for educating children',\n", + " 'pen': 'a tool for writing or drawing with ink',\n", + " 'pencil': 'a writing implement with a graphite or colored core',\n", + " 'phone': 'a device used to communicate through sound or speech',\n", + " 'television': 'a system for transmitting visual images and sound',\n", + " 'watch': 'a small timepiece worn on the wrist',\n", + " 'shoe': 'a covering for the foot',\n", + " 'shirt': 'a garment worn on the upper part of the body',\n", + " 'pants': 'an outer garment covering the body from the waist to the ankles',\n", + " 'hat': 'a covering for the head',\n", + " 'garden': 'a plot of ground where plants are cultivated',\n", + " 'river': 'a large natural stream of water',\n", + " 'lake': 'a large body of water surrounded by land',\n", + " 'beach': 'a sandy or pebbly shore by the ocean',\n", + " 'rain': 'water falling in drops from the atmosphere',\n", + " 'snow': 'atmospheric water vapor frozen into ice crystals',\n", + " 'cloud': 'a visible mass of condensed water vapor',\n", + " 'bird': 'a warm-blooded vertebrate with feathers and beak',\n", + " 'fish': 'a limbless cold-blooded vertebrate with gills',\n", + " 'insect': 'a small arthropod with six legs and typically wings',\n", + " 'computer': 'an electronic device for storing and processing data',\n", + " 'table': 'a piece of furniture with a flat top and legs',\n", + " 'chair': 'a separate seat for one person',\n", + " 'lamp': 'a device for giving light',\n", + " 'door': 'a hinged, sliding, or revolving barrier for closing an opening',\n", + " 'window': 'an opening in a wall to let in light and air',\n", + " 'wall': 'a continuous vertical brick or stone structure',\n", + " 'bookcase': 'a piece of furniture with shelves for books',\n", + " 'clock': 'a timepiece that shows the time',\n", + " 'guitar': 'a musical instrument with strings',\n", + " 'piano': 'a large musical instrument with a keyboard',\n", + " 'singer': 'a person who sings',\n", + " 'artist': 'a person who creates visual or performing arts',\n", + " 'chef': 'a professional cook',\n", + " 'doctor': 'a person trained in medicine',\n", + " 'firefighter': 'a person who extinguishes fires',\n", + " 'pilot': 'a person who operates an aircraft',\n", + " 'teacher': 'a person who educates others',\n", + " 'actor': 'a person who performs in plays or movies',\n", + " 'dentist': 'a person who treats teeth and oral health',\n", + " 'engineer': 'a person who designs and builds machines or structures',\n", + " 'waiter': 'a person who serves food in a restaurant',\n", + " 'police': 'a civil force responsible for maintaining law and order',\n", + " 'nurse': 'a person trained to care for the sick or infirm',\n", + " 'writer': 'a person who writes books, stories, or articles',\n", + " 'scientist': 'a person who conducts scientific research',\n", + " 'musician': 'a person who plays a musical instrument',\n", + " 'photographer': 'a person who takes photographs',\n", + " 'baker': 'a person who bakes bread and cakes',\n", + " 'painter': 'a person who creates paintings',\n", + " 'dancer': 'a person who performs dance',\n", + " 'engineer': 'a person who designs and builds machines or structures',\n", + " 'architect': 'a person who designs buildings and structures',\n", + " 'astronaut': 'a person trained for space travel',\n", + " 'athlete': 'a person proficient in sports and other physical exercises',\n", + " 'biologist': 'a person who studies living organisms',\n", + " 'economist': 'a person who studies economic systems',\n", + " 'geologist': 'a person who studies the earth and its history',\n", + " 'historian': 'a person who studies and writes about the past',\n", + " 'journalist': 'a person who reports news and events',\n", + " 'lawyer': 'a person who practices law and represents clients',\n", + " 'mathematician': 'a person who studies mathematics',\n", + " 'physicist': 'a person who studies the fundamental nature of the universe',\n", + " 'psychologist': 'a person who studies the mind and behavior',\n", + " 'sociologist': 'a person who studies society and social behavior',\n", + "}" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "id": "leplCwghAFwn" + }, + "outputs": [], + "source": [ + "# Grammar exercise containing sentences with fill in the blank format.\n", + "grammar_exercise = [\n", + " {\n", + " 'question': 'He ___ to the store every day.',\n", + " 'answer': 'goes'\n", + " },\n", + " {\n", + " 'question': 'They ___ in the park yesterday.',\n", + " 'answer': 'played'\n", + " },\n", + " {\n", + " 'question': 'She ___ a song beautifully.',\n", + " 'answer': 'sings'\n", + " },\n", + " {\n", + " 'question': 'I ___ my homework yesterday.',\n", + " 'answer': 'did'\n", + " },\n", + " {\n", + " 'question': 'We ___ lunch at noon.',\n", + " 'answer': 'have'\n", + " },\n", + " {\n", + " 'question': 'It ___ raining outside.',\n", + " 'answer': 'is'\n", + " },\n", + " {\n", + " 'question': 'They ___ going to the party.',\n", + " 'answer': 'are'\n", + " },\n", + " {\n", + " 'question': 'He ___ reading a book.',\n", + " 'answer': 'is'\n", + " },\n", + " {\n", + " 'question': 'She ___ her friend tomorrow.',\n", + " 'answer': 'will see'\n", + " },\n", + " {\n", + " 'question': 'We ___ to the beach last summer.',\n", + " 'answer': 'went'\n", + " },\n", + " {\n", + " 'question': 'The birds ___ in the sky.',\n", + " 'answer': 'fly'\n", + " },\n", + " {\n", + " 'question': 'The sun ___ in the east.',\n", + " 'answer': 'rises'\n", + " },\n", + " {\n", + " 'question': 'I ___ English for two years.',\n", + " 'answer': 'have been studying'\n", + " },\n", + " {\n", + " 'question': 'He ___ his bike last week.',\n", + " 'answer': 'fixed'\n", + " },\n", + " {\n", + " 'question': 'She ___ breakfast at 8 AM.',\n", + " 'answer': 'eats'\n", + " },\n", + " {\n", + " 'question': 'They ___ a movie tonight.',\n", + " 'answer': 'will watch'\n", + " },\n", + " {\n", + " 'question': 'The baby ___ asleep.',\n", + " 'answer': 'is'\n", + " },\n", + " {\n", + " 'question': 'We ___ the test yesterday.',\n", + " 'answer': 'passed'\n", + " },\n", + " {\n", + " 'question': 'I ___ to the radio every morning.',\n", + " 'answer': 'listen'\n", + " },\n", + " {\n", + " 'question': 'He ___ a letter to his friend.',\n", + " 'answer': 'wrote'\n", + " },\n", + " {\n", + " 'question': 'She ___ a picture of the sunset.',\n", + " 'answer': 'took'\n", + " },\n", + " {\n", + " 'question': 'They ___ the cookies yesterday.',\n", + " 'answer': 'ate'\n", + " },\n", + " {\n", + " 'question': 'I ___ in this city for five years.',\n", + " 'answer': 'have lived'\n", + " },\n", + " {\n", + " 'question': 'He ___ late for school yesterday.',\n", + " 'answer': 'was'\n", + " },\n", + " {\n", + " 'question': 'She ___ at the party tonight.',\n", + " 'answer': 'will dance'\n", + " },\n", + " {\n", + " 'question': 'We ___ a new car next week.',\n", + " 'answer': 'are buying'\n", + " },\n", + " {\n", + " 'question': 'The sun ___ in the west.',\n", + " 'answer': 'sets'\n", + " },\n", + " {\n", + " 'question': 'I ___ my keys yesterday.',\n", + " 'answer': 'lost'\n", + " },\n", + " {\n", + " 'question': 'He ___ his grandmother every Sunday.',\n", + " 'answer': 'visits'\n", + " },\n", + " {\n", + " 'question': 'She ___ her hair last month.',\n", + " 'answer': 'cut'\n", + " },\n", + " {\n", + " 'question': 'They ___ a good time at the party.',\n", + " 'answer': 'had'\n", + " },\n", + " {\n", + " 'question': 'I ___ the book last night.',\n", + " 'answer': 'read'\n", + " },\n", + " {\n", + " 'question': 'We ___ a lot of pictures on our vacation.',\n", + " 'answer': 'took'\n", + " },\n", + " {\n", + " 'question': 'He ___ a cup of coffee every morning.',\n", + " 'answer': 'drinks'\n", + " },\n", + " {\n", + " 'question': 'She ___ for her friend at the airport.',\n", + " 'answer': 'is waiting'\n", + " },\n", + " {\n", + " 'question': 'They ___ a pizza for dinner tonight.',\n", + " 'answer': 'will order'\n", + " },\n", + " {\n", + " 'question': 'I ___ with my friends last weekend.',\n", + " 'answer': 'played'\n", + " },\n", + " {\n", + " 'question': 'We ___ the movie last night.',\n", + " 'answer': 'watched'\n", + " },\n", + " {\n", + " 'question': 'He ___ in the garden every day.',\n", + " 'answer': 'works'\n", + " },\n", + " {\n", + " 'question': 'She ___ her sister this evening.',\n", + " 'answer': 'will meet'\n", + " },\n", + " {\n", + " 'question': 'They ___ to the mountains last summer.',\n", + " 'answer': 'went'\n", + " },\n", + " {\n", + " 'question': 'I ___ Spanish at school.',\n", + " 'answer': 'study'\n", + " },\n", + " {\n", + " 'question': 'He ___ his bike to work.',\n", + " 'answer': 'rides'\n", + " },\n", + " {\n", + " 'question': 'She ___ breakfast at 7 AM.',\n", + " 'answer': 'eats'\n", + " },\n", + " {\n", + " 'question': 'They ___ a movie last night.',\n", + " 'answer': 'watched'\n", + " },\n", + " {\n", + " 'question': 'The baby ___ up from a nap.',\n", + " 'answer': 'woke'\n", + " },\n", + " {\n", + " 'question': 'We ___ the test two days ago.',\n", + " 'answer': 'took'\n", + " },\n", + " {\n", + " 'question': 'I ___ to music every day.',\n", + " 'answer': 'listen'\n", + " },\n", + " {\n", + " 'question': 'He ___ a letter to his friend last week.',\n", + " 'answer': 'wrote'\n", + " },\n", + " {\n", + " 'question': 'She ___ a picture of the sunrise.',\n", + " 'answer': 'took'\n", + " },\n", + " {\n", + " 'question': 'They ___ the cookies yesterday.',\n", + " 'answer': 'ate'\n", + " },\n", + " {\n", + " 'question': 'I ___ in this city since 2010.',\n", + " 'answer': 'have lived'\n", + " },\n", + " {\n", + " 'question': 'He ___ late for school yesterday.',\n", + " 'answer': 'was'\n", + " },\n", + " {\n", + " 'question': 'She ___ at the party tomorrow.',\n", + " 'answer': 'will dance'\n", + " },\n", + " {\n", + " 'question': 'We ___ a new car next month.',\n", + " 'answer': 'are buying'\n", + " },\n", + " {\n", + " 'question': 'The sun ___ in the east.',\n", + " 'answer': 'rises'\n", + " },\n", + " {\n", + " 'question': 'I ___ my keys yesterday morning.',\n", + " 'answer': 'lost'\n", + " },\n", + " {\n", + " 'question': 'He ___ his grandmother every week.',\n", + " 'answer': 'visits'\n", + " },\n", + " {\n", + " 'question': 'She ___ her hair last week.',\n", + " 'answer': 'cut'\n", + " },\n", + " {\n", + " 'question': 'They ___ a good time at the party.',\n", + " 'answer': 'had'\n", + " },\n", + " {\n", + " 'question': 'I ___ the book yesterday evening.',\n", + " 'answer': 'read'\n", + " },\n", + " {\n", + " 'question': 'We ___ a lot of pictures on our vacation.',\n", + " 'answer': 'took'\n", + " },\n", + " {\n", + " 'question': 'He ___ a cup of coffee every morning.',\n", + " 'answer': 'drinks'\n", + " },\n", + " {\n", + " 'question': 'She ___ for her friend at the airport.',\n", + " 'answer': 'is waiting'\n", + " },\n", + " {\n", + " 'question': 'They ___ a pizza for dinner tonight.',\n", + " 'answer': 'will order'\n", + " },\n", + " {\n", + " 'question': 'I ___ with my friends last Saturday.',\n", + " 'answer': 'played'\n", + " },\n", + " {\n", + " 'question': 'We ___ the movie last night.',\n", + " 'answer': 'watched'\n", + " },\n", + " {\n", + " 'question': 'He ___ in the garden every day.',\n", + " 'answer': 'works'\n", + " },\n", + " {\n", + " 'question': 'She ___ her sister this evening.',\n", + " 'answer': 'will meet'\n", + " },\n", + " {\n", + " 'question': 'They ___ to the mountains last summer.',\n", + " 'answer': 'went'\n", + " },\n", + " {\n", + " 'question': 'I ___ Spanish at school.',\n", + " 'answer': 'study'\n", + " },\n", + " {\n", + " 'question': 'He ___ his bike to work every day.',\n", + " 'answer': 'rides'\n", + " },\n", + " {\n", + " 'question': 'She ___ breakfast at 7 AM.',\n", + " 'answer': 'eats'\n", + " },\n", + " {\n", + " 'question': 'They ___ a movie last night.',\n", + " 'answer': 'watched'\n", + " },\n", + " {\n", + " 'question': 'The baby ___ up from a nap.',\n", + " 'answer': 'woke'\n", + " },\n", + " {\n", + " 'question': 'We ___ the test two days ago.',\n", + " 'answer': 'took'\n", + " },\n", + " {\n", + " 'question': 'I ___ to music every day.',\n", + " 'answer': 'listen'\n", + " },\n", + " {\n", + " 'question': 'He ___ a letter to his friend last week.',\n", + " 'answer': 'wrote'\n", + " },\n", + " {\n", + " 'question': 'She ___ a picture of the sunrise.',\n", + " 'answer': 'took'\n", + " },\n", + " {\n", + " 'question': 'They ___ the cookies yesterday.',\n", + " 'answer': 'ate'\n", + " },\n", + " {\n", + " 'question': 'I ___ in this city since 2010.',\n", + " 'answer': 'have lived'\n", + " },\n", + " {\n", + " 'question': 'He ___ late for school yesterday.',\n", + " 'answer': 'was'\n", + " },\n", + " {\n", + " 'question': 'She ___ at the party tomorrow.',\n", + " 'answer': 'will dance'\n", + " },\n", + " {\n", + " 'question': 'We ___ a new car next month.',\n", + " 'answer': 'are buying'\n", + " },\n", + " {\n", + " 'question': 'The sun ___ in the east.',\n", + " 'answer': 'rises'\n", + " },\n", + " {\n", + " 'question': 'I ___ my keys yesterday morning.',\n", + " 'answer': 'lost'\n", + " },\n", + " {\n", + " 'question': 'He ___ his grandmother every week.',\n", + " 'answer': 'visits'\n", + " },\n", + " {\n", + " 'question': 'She ___ her hair last week.',\n", + " 'answer': 'cut'\n", + " },\n", + " {\n", + " 'question': 'They ___ a good time at the party.',\n", + " 'answer': 'had'\n", + " },\n", + " {\n", + " 'question': 'I ___ the book yesterday evening.',\n", + " 'answer': 'read'\n", + " },\n", + " {\n", + " 'question': 'We ___ a lot of pictures on our vacation.',\n", + " 'answer': 'took'\n", + " },\n", + " {\n", + " 'question': 'He ___ a cup of coffee every morning.',\n", + " 'answer': 'drinks'\n", + " },\n", + " {\n", + " 'question': 'She ___ for her friend at the airport.',\n", + " 'answer': 'is waiting'\n", + " },\n", + " {\n", + " 'question': 'They ___ a pizza for dinner tonight.',\n", + " 'answer': 'will order'\n", + " },\n", + " {\n", + " 'question': 'I ___ with my friends last Saturday.',\n", + " 'answer': 'played'\n", + " },\n", + " {\n", + " 'question': 'We ___ the movie last night.',\n", + " 'answer': 'watched'\n", + " },\n", + "]" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "id": "ZoIB9EK1AJiK" + }, + "outputs": [], + "source": [ + "# Conversation containing common questions and answers\n", + "conversations = [\n", + " {\n", + " 'question': 'What is your favorite color?',\n", + " 'answer': 'My favorite color is blue.'\n", + " },\n", + " {\n", + " 'question': 'Do you enjoy learning new things?',\n", + " 'answer': 'Yes, I love learning new things and expanding my knowledge.'\n", + " },\n", + " {\n", + " 'question': 'What languages can you speak?',\n", + " 'answer': 'I can speak English and Spanish fluently.'\n", + " },\n", + " {\n", + " 'question': 'Tell me a fun fact!',\n", + " 'answer': 'Sure! Did you know that honey never spoils? Archaeologists have found pots of honey in ancient Egyptian tombs that are over 3,000 years old and still perfectly edible!'\n", + " },\n", + " {\n", + " 'question': 'What do you like to do in your free time?',\n", + " 'answer': 'In my free time, I enjoy reading books and going for long walks.'\n", + " },\n", + " {\n", + " 'question': 'What\\'s your favorite book or movie?',\n", + " 'answer': 'I really love the book \"To Kill a Mockingbird\" by Harper Lee.'\n", + " },\n", + " {\n", + " 'question': 'How do you stay motivated?',\n", + " 'answer': 'I stay motivated by setting goals and staying focused on achieving them.'\n", + " },\n", + " {\n", + " 'question': 'What are your goals for the future?',\n", + " 'answer': 'My goals include traveling to different countries and learning new languages.'\n", + " },\n", + " {\n", + " 'question': 'What\\'s the most interesting language fact you know?',\n", + " 'answer': 'One fascinating fact is that the Inuit language has over 50 different words for \"snow\"!'\n", + " },\n", + " {\n", + " 'question': 'Tell me about an inspiring language learner!',\n", + " 'answer': 'Sure! There is a polyglot named Ziad Fazah who holds the Guinness World Record for speaking the most languages. He can speak 59 languages fluently!'\n", + " },\n", + " {\n", + " 'question': 'How do you deal with language learning challenges?',\n", + " 'answer': 'I overcome language learning challenges by practicing regularly and seeking help from language exchange partners.'\n", + " },\n", + " {\n", + " 'question': 'What advice would you give to new language learners?',\n", + " 'answer': 'My advice is to be patient with yourself, practice consistently, and immerse yourself in the language as much as possible.'\n", + " },\n", + " {\n", + " 'question': 'What\\'s the best way to learn vocabulary?',\n", + " 'answer': 'Learning vocabulary through context and using flashcards or mnemonic techniques can be very effective.'\n", + " },\n", + " {\n", + " 'question': 'Can you recommend any language learning resources?',\n", + " 'answer': 'Certainly! There are many great language learning apps and websites like Duolingo, Memrise, and FluentU.'\n", + " },\n", + " {\n", + " 'question': 'What are the benefits of being multilingual?',\n", + " 'answer': 'Being multilingual opens up opportunities for better communication, cultural understanding, and career prospects.'\n", + " },\n", + " {\n", + " 'question': 'How can I improve my pronunciation?',\n", + " 'answer': 'Practicing with native speakers, listening to authentic materials, and using pronunciation apps can be helpful.'\n", + " },\n", + " {\n", + " 'question': 'What\\'s the most challenging language to learn?',\n", + " 'answer': 'The difficulty of learning a language varies for each individual, but some consider languages with complex grammar and writing systems, like Mandarin Chinese or Arabic, to be challenging.'\n", + " },\n", + " {\n", + " 'question': 'How do you celebrate language learning milestones?',\n", + " 'answer': 'I celebrate language learning milestones by treating myself to a nice meal or doing something I enjoy.'\n", + " },\n", + " {\n", + " 'question': 'What are some common language learning myths?',\n", + " 'answer': 'One common myth is that you need to be naturally talented to learn a language. In reality, dedication and practice are more important.'\n", + " },\n", + " {\n", + " 'question': 'What languages are you currently learning?',\n", + " 'answer': 'Currently, I am focusing on improving my French and learning German.'\n", + " },\n", + " {\n", + " 'question': 'What language learning techniques do you use?',\n", + " 'answer': 'I use various techniques, including spaced repetition, interactive quizzes, and language immersion.'\n", + " },\n", + "]\n" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": { + "id": "QXQng37SAL-S" + }, + "outputs": [], + "source": [ + "#\n", + "def vocabulary_quiz():\n", + " # Introduction to the quiz.\n", + " print(\"AI Language Learning Assistant: Vocabulary Quiz\")\n", + " \n", + " # Initialize the user's score to zero.\n", + " score = 0\n", + " \n", + " # Create a list of words to quiz the user on, using the keys from the vocabulary dictionary.\n", + " quiz_items = list(vocabulary.keys())\n", + " \n", + " # Shuffle the list of words to randomize the order of the questions.\n", + " random.shuffle(quiz_items)\n", + "\n", + " # Loop through each word in the shuffled list.\n", + " for word in quiz_items:\n", + " # Prompt the user to provide a definition for the given word.\n", + " user_answer = input(f\"What does '{word}' mean? \")\n", + " \n", + " # Check if the user's answer matches the definition in the vocabulary dictionary.\n", + " if user_answer.strip().lower() == vocabulary[word].lower():\n", + " print(\"Correct!\") # If the answer is correct, acknowledge it.\n", + " score += 1 # Increase the score by 1.\n", + " else:\n", + " # If the answer is incorrect, provide the correct definition.\n", + " print(f\"Wrong. The correct answer is: {vocabulary[word]}\")\n", + "\n", + " # Display the user's final score at the end of the quiz.\n", + " print(f\"Quiz completed! Your score: {score}/{len(vocabulary)}\")\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "CjSExrPyAQe3" + }, + "outputs": [], + "source": [ + "def grammar_exercise_quiz():\n", + " # Introduction to the grammar exercise.\n", + " print(\"AI Language Learning Assistant: Grammar Exercise\")\n", + " \n", + " # Initialize the user's score to zero.\n", + " score = 0\n", + "\n", + " # Loop through each grammar exercise item in the grammar_exercise list.\n", + " for item in grammar_exercise:\n", + " # Prompt the user to answer the grammar question.\n", + " user_answer = input(item['question'] + \" \")\n", + " \n", + " # Check if the user's answer matches the correct answer in the grammar_exercise item.\n", + " if user_answer.strip().lower() == item['answer'].lower():\n", + " print(\"Correct!\") # If the answer is correct, acknowledge it.\n", + " score += 1 # Increase the score by 1.\n", + " else:\n", + " # If the answer is incorrect, provide the correct answer.\n", + " print(f\"Wrong. The correct answer is: {item['answer']}\")\n", + "\n", + " # Display the user's final score at the end of the grammar exercise.\n", + " print(f\"Grammar exercise completed! Your score: {score}/{len(grammar_exercise)}\")\n" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": { + "id": "yM93JO09AR9I" + }, + "outputs": [], + "source": [ + "def interactive_conversation_practice():\n", + " # Introduction to the interactive conversation practice.\n", + " print(\"AI Language Learning Assistant: Interactive Conversation Practice\")\n", + " \n", + " # Instructions for the user to exit the conversation.\n", + " print(\"Type 'exit' to end the conversation.\")\n", + "\n", + " # Start an infinite loop to allow continuous conversation until the user exits.\n", + " while True:\n", + " # Randomly select a conversation prompt from the 'conversations' list.\n", + " conversation = random.choice(conversations)\n", + " \n", + " # Display the chatbot's question and prompt the user for input.\n", + " user_input = input(\"ChatBot: \" + conversation['question'] + \" \")\n", + " \n", + " # Check if the user wants to exit the conversation.\n", + " if user_input.lower() == 'exit':\n", + " break # Exit the loop if the user types 'exit'.\n", + " \n", + " # Display the chatbot's response based on the selected conversation prompt.\n", + " print(\"ChatBot:\", conversation['answer'])\n" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/", + "height": 1000 + }, + "id": "nhguaeyLAUAo", + "outputId": "b650ba83-b0ea-466c-d5b7-0d1403db49a7" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "AI Language Learning Assistant: Vocabulary Quiz\n", + "What does 'mathematician' mean? v\n", + "Wrong. The correct answer is: a person who studies mathematics\n", + "What does 'apple' mean? v\n", + "Wrong. The correct answer is: a fruit\n", + "What does 'piano' mean? s\n", + "Wrong. The correct answer is: a large musical instrument with a keyboard\n", + "What does 'run' mean? s\n", + "Wrong. The correct answer is: move at a speed faster than a walk\n", + "What does 'phone' mean? s\n", + "What does 'window' mean? s\n", + "Wrong. The correct answer is: a device used to communicate through sound or speech\n", + "Wrong. The correct answer is: an opening in a wall to let in light and air\n", + "What does 'bicycle' mean? a\n", + "Wrong. The correct answer is: a vehicle with two wheels, powered by pedals\n", + "What does 'architect' mean? e\n", + "Wrong. The correct answer is: a person who designs buildings and structures\n", + "What does 'wall' mean? e\n", + "Wrong. The correct answer is: a continuous vertical brick or stone structure\n", + "What does 'clock' mean? e\n", + "Wrong. The correct answer is: a timepiece that shows the time\n", + "What does 'astronaut' mean? e\n", + "Wrong. The correct answer is: a person trained for space travel\n", + "What does 'book' mean? e\n", + "Wrong. The correct answer is: a written or printed work consisting of pages glued or sewn together along one side\n", + "What does 'nurse' mean? q\n", + "Wrong. The correct answer is: a person trained to care for the sick or infirm\n", + "What does 'hat' mean? q\n", + "Wrong. The correct answer is: a covering for the head\n", + "What does 'shoe' mean? e\n", + "Wrong. The correct answer is: a covering for the foot\n", + "What does 'doctor' mean? q\n", + "Wrong. The correct answer is: a person trained in medicine\n", + "What does 'mountain' mean? e\n", + "Wrong. The correct answer is: a large natural elevation of the earth's surface\n", + "What does 'house' mean? q\n", + "Wrong. The correct answer is: a building for human habitation\n" + ] + }, + { + "ename": "KeyboardInterrupt", + "evalue": "Interrupted by user", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mKeyboardInterrupt\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[1;32m 24\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"Sorry, there was an error processing the audio. Please try again.\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 25\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 26\u001b[0;31m \u001b[0mvocabulary_quiz\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 27\u001b[0m \u001b[0mgrammar_exercise_quiz\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 28\u001b[0m \u001b[0minteractive_conversation_practice\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m\u001b[0m in \u001b[0;36mvocabulary_quiz\u001b[0;34m()\u001b[0m\n\u001b[1;32m 6\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 7\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mword\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mquiz_items\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 8\u001b[0;31m \u001b[0muser_answer\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0minput\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34mf\"What does '{word}' mean? \"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 9\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0muser_answer\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mstrip\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mlower\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;34m==\u001b[0m \u001b[0mvocabulary\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mword\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mlower\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 10\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"Correct!\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/usr/local/lib/python3.10/dist-packages/ipykernel/kernelbase.py\u001b[0m in \u001b[0;36mraw_input\u001b[0;34m(self, prompt)\u001b[0m\n\u001b[1;32m 849\u001b[0m \u001b[0;34m\"raw_input was called, but this frontend does not support input requests.\"\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 850\u001b[0m )\n\u001b[0;32m--> 851\u001b[0;31m return self._input_request(str(prompt),\n\u001b[0m\u001b[1;32m 852\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_parent_ident\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 853\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_parent_header\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/usr/local/lib/python3.10/dist-packages/ipykernel/kernelbase.py\u001b[0m in \u001b[0;36m_input_request\u001b[0;34m(self, prompt, ident, parent, password)\u001b[0m\n\u001b[1;32m 893\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0mKeyboardInterrupt\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 894\u001b[0m \u001b[0;31m# re-raise KeyboardInterrupt, to truncate traceback\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 895\u001b[0;31m \u001b[0;32mraise\u001b[0m \u001b[0mKeyboardInterrupt\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"Interrupted by user\"\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 896\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0mException\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0me\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 897\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mlog\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mwarning\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"Invalid Message:\"\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mexc_info\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mTrue\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;31mKeyboardInterrupt\u001b[0m: Interrupted by user" + ] + } + ], + "source": [ + "def detect_pronunciation_errors():\n", + " # Introduction to the pronunciation errors detection feature.\n", + " print(\"AI Language Learning Assistant: Pronunciation Errors Detection\")\n", + "\n", + " # Initialize the speech recognizer.\n", + " recognizer = sr.Recognizer()\n", + " \n", + " # Use the microphone to capture audio input from the user.\n", + " with sr.Microphone() as source:\n", + " print(\"Speak a sentence for pronunciation evaluation:\")\n", + " \n", + " # Adjust for any ambient noise to improve recognition accuracy.\n", + " recognizer.adjust_for_ambient_noise(source)\n", + " \n", + " # Listen to the audio input from the user.\n", + " audio = recognizer.listen(source)\n", + "\n", + " try:\n", + " # Attempt to recognize the speech using Google's speech recognition service.\n", + " user_sentence = recognizer.recognize_google(audio)\n", + "\n", + " # Compare the recognized sentence with a pre-defined correct sentence to detect pronunciation errors.\n", + " # For simplicity, we're using a fixed correct sentence.\n", + " correct_sentence = \"I love learning languages.\"\n", + " \n", + " # Check if the user's sentence matches the correct sentence.\n", + " if user_sentence.strip().lower() == correct_sentence.lower():\n", + " print(\"Your pronunciation is great!\") # Inform the user if pronunciation is correct.\n", + " else:\n", + " print(\"There might be some pronunciation errors. Keep practicing!\") # Encourage more practice if errors are detected.\n", + " \n", + " # Handle cases where the speech was not understood by the recognizer.\n", + " except sr.UnknownValueError:\n", + " print(\"Sorry, I couldn't understand what you said.\")\n", + " \n", + " # Handle cases where there was an error in processing the audio input.\n", + " except sr.RequestError:\n", + " print(\"Sorry, there was an error processing the audio. Please try again.\")\n", + "\n", + "# Calling the vocabulary quiz function to test vocabulary knowledge.\n", + "vocabulary_quiz()\n", + "\n", + "# Calling the grammar exercise quiz function to practice grammar.\n", + "grammar_exercise_quiz()\n", + "\n", + "# Calling the interactive conversation practice function for conversation practice.\n", + "interactive_conversation_practice()\n", + "\n", + "# Calling the pronunciation errors detection function to evaluate pronunciation.\n", + "detect_pronunciation_errors()\n" + ] + } + ], + "metadata": { + "colab": { + "provenance": [] + }, + "kernelspec": { + "display_name": "Python 3", + "name": "python3" + }, + "language_info": { + "name": "python" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/AI_Language_Learning_Assistant/README.md b/AI_Language_Learning_Assistant/README.md new file mode 100644 index 0000000000..99cfd452ad --- /dev/null +++ b/AI_Language_Learning_Assistant/README.md @@ -0,0 +1,40 @@ +# Language Learning Assistant + +## Introduction +This is a Python script for a language learning assistant that helps users practice their target language. It provides interactive conversation practice, vocabulary quizzes, grammar exercises, and pronunciation error detection. This script aims to enhance language learning experiences and make the process enjoyable. + +## Features +- Interactive conversation practice with a variety of questions and answers. +- Vocabulary quizzes to test and reinforce your knowledge. +- Grammar exercises to improve your understanding of sentence structures. +- Pronunciation error detection to help you refine your speaking skills. + +## Requirements +- Python 3.x +- random +- speech_recognition + +## Getting Started +1. Clone this repository to your local machine. +2. Make sure you have Python 3.x installed. +3. Open a terminal or command prompt and navigate to the project directory. +4. Run the `language_learning_assistant.py` script using the following command: + +```bash +python language_learning_assistant.py +``` +## How to Use +- Upon running the script, you will be prompted to choose from conversation practice, vocabulary quiz, grammar exercise, or pronunciation error detection. +- For conversation practice, answer the questions displayed and receive responses. +- In the vocabulary quiz, enter the correct word corresponding to the given meaning. +- For grammar exercises, fill in the blanks with the appropriate verb forms or words. +- The pronunciation error detection feature will evaluate your spoken input and provide feedback. + +## Vocabulary Words +The script includes a set of vocabulary words and their meanings that you can practice with during the vocabulary quiz. You can customize this list by modifying the `vocabulary` dictionary in the script. + +## Conversation Questions and Answers +The script offers a set of conversation questions and answers to engage in interactive conversation practice. You can add more questions and responses to this list in the script for a varied learning experience. + +## Grammar Exercises +The grammar exercise section contains fill-in-the-blank sentences to help you improve your grasp of grammar rules. You can extend this section by adding more sentences and exercises to the `grammar_exercise` list in the script. \ No newline at end of file