def choose_save(saves):
    valid = False

    mike.mike("saved languages include ")
    for s in saves:
        mike.mike(extras.get_language_long(s))
    language = mike.record_audio(
        "Which language would you like to continue learning?")
    print("You have chosen: " + language)
    while valid == False:
        try:
            language = extras.get_language_short(language)
        except:
            return

        if language in saves:
            level = check_saves(progress['name'], language)
            progress['language'] = language
            progress['level'] = str(level)
            valid = True
        else:
            language = mike.record_audio(
                "I'm sorry, that is not a valid option. Choose a different language."
            )
            print("You have chosen: " + language)
def test_l1(lan):
    language = extras.get_language_long(lan)
    count = 0
    tPoints = 0
    # Five questions to test the most basic words
    while count < 3:
        if count % 2 == 0:
            phrase = random_test.easy_noun()
        else:
            phrase = random_test.easy_adj()

        userAnswer = mike.record_audio(
            "What is " + phrase + " in " + language + "?", lan)
        translated = GoogleTranslator(source='auto',
                                      target=lan).translate(text=phrase)
        print("You said: " + userAnswer + "\n The correct answer was: " +
              translated)
        count = count + 1
        if len(userAnswer) > 0:
            if userAnswer in translated:
                print("+1")
                tPoints = tPoints + 1

    if tPoints > 2:
        tPoints = 2
    percent = (tPoints / 2) * 100
    return percent
示例#3
0
def numbers(lan):

    language = extras.get_language_long(lan)
    print("\n\nNumbers in " + language)
    print("---------------------------------------------------------")

    numEn = [
        "zero", "one", "two", "three", "four", "five", "six", "seven", "eight",
        "nine", "ten"
    ]

    numL = []
    for n in numEn:
        numOth = GoogleTranslator(source='en', target=lan).translate(text=n)
        numOth = numOth.lower()
        numL.append(numOth)

    newP = 0
    i = 0
    while i < 11:
        correct = False
        mike.mike(numEn[i] + " in " + language + " is ")
        mike.mike(numL[i], lan)

        mike.mike("Say " + numEn[i] + " in " + language)
        user_input = mike.record_audio(lang=lan)
        attempt = 0
        while correct == False:
            print("You said: " + user_input)
            if numL[i] in user_input:
                print("Correct!")
                newP = newP + 1
                correct = True
            elif str(i) in user_input:
                print("Correct!")
                newP = newP + 1
                correct = True
            elif "quit" in user_input:
                main.save_progress()
                exit()
            else:
                if attempt < 3:
                    mike.mike("Let's try again, say ")
                    user_input = mike.record_audio(numL[i], lan)
                else:
                    print("Let's move on")
                    correct = True
                attempt = attempt + 1

        i = i + 1

    return newP
示例#4
0
def colours(lan):

    language = extras.get_language_long(lan)

    print("\n\nColours in " + language)
    print("---------------------------------------------------------")
    clrEn = [
        "white", "grey", "black", "brown", "red", "green", "blue", "yellow",
        "pink", "purple", "orange"
    ]
    clrL = []
    for n in clrEn:
        clrOth = GoogleTranslator(source='en', target=lan).translate(text=n)
        clrOth = clrOth.lower()
        clrL.append(clrOth)

    i = 0
    newP = 0

    while i < 11:
        correct = False
        mike.mike(clrEn[i] + " in " + language + " is ")
        mike.mike(clrL[i], lan)

        mike.mike("Say " + clrEn[i] + " in " + language)
        user_input = mike.record_audio(lang=lan)
        user_input = user_input.lower()
        attempt = 0
        while correct == False:
            print("You said: " + user_input)
            if clrL[i] in user_input:
                print("Correct!")
                newP = newP + 1

                correct = True
            elif "quit" in user_input:
                main.save_progress()
                exit()
            else:
                if attempt < 3:
                    mike.mike("Let's try again, say ")
                    user_input = mike.record_audio(clrL[i], lan)
                else:
                    print("Let's move on")
                    correct = True
                attempt = attempt + 1

        i = i + 1

    return newP
示例#5
0
def transport(lan):

    language = extras.get_language_long(lan)
    print("\n\nTransport in " + language)
    print("---------------------------------------------------------")

    numEn = ["cycling", "running", "walking", "driving", "flying",
             "sailing", "train", "boat", "airplane", "car", "bus"]

    numL = []
    for n in numEn:
        numOth = GoogleTranslator(
            source='en', target=lan).translate(text=n)
        numOth = numOth.lower()
        numL.append(numOth)

    newP = 0
    i = 0
    while i < 11:
        correct = False
        mike.mike(numEn[i] + " in " + language + " is ")
        mike.mike(numL[i], lan)

        mike.mike("Say " + numEn[i] + " in " + language)
        user_input = mike.record_audio(lang=lan)
        attempt = 0
        while correct == False:
            print("You said: " + user_input)
            if numL[i] in user_input:
                print("Correct!")
                newP = newP + 1
                correct = True
            elif "quit" in user_input:
                main.save_progress()
                exit()
            else:
                if attempt < 3:
                    mike.mike("Let's try again, say ")
                    user_input = mike.record_audio(numL[i], lan)
                else:
                    print("Let's move on")
                    correct = True
                attempt = attempt + 1
        i = i + 1

    return newP
示例#6
0
def clothes(lan):

    language = extras.get_language_long(lan)
    print("\n\nClothes in " + language)
    print("---------------------------------------------------------")

    numEn = ["blouse", "t-shirt", "hoodie", "pants", "jeans",
             "socks", "shoes", "belt", "hat", "scarf", "jacket"]

    numL = []
    for n in numEn:
        numOth = GoogleTranslator(
            source='en', target=lan).translate(text=n)
        numOth = numOth.lower()
        numL.append(numOth)

    newP = 0
    i = 0
    while i < 11:
        correct = False
        mike.mike(numEn[i] + " in " + language + " is ")
        mike.mike(numL[i], lan)

        mike.mike("Say " + numEn[i] + " in " + language)
        user_input = mike.record_audio(lang=lan)
        attempt = 0
        while correct == False:
            print("You said: " + user_input)
            if numL[i] in user_input:
                print("Correct!")
                newP = newP + 1
                correct = True
            elif "quit" in user_input:
                main.save_progress()
                exit()
            else:
                if attempt < 3:
                    mike.mike("Let's try again, say ")
                    user_input = mike.record_audio(numL[i], lan)
                else:
                    print("Let's move on")
                    correct = True
                attempt = attempt + 1
        i = i + 1

    return newP
示例#7
0
def animals(lan):
    language = extras.get_language_long(lan)
    print("\n\nAnimals in " + language)
    print("---------------------------------------------------------")
    anmEn = [
        "dog", "cat", "cow", "horse", "lion", "monkey", "snake", "turtle",
        "bear", "tiger", "sheep"
    ]
    anmL = []
    for n in anmEn:
        anmOth = GoogleTranslator(source='en', target=lan).translate(text=n)
        anmOth = anmOth.lower()
        anmL.append(anmOth)

    i = 0
    newP = 0
    while i < 11:
        correct = False
        mike.mike(anmEn[i] + " in " + language + " is ")
        mike.mike(anmL[i], lan)

        mike.mike("Say " + anmEn[i] + " in " + language)
        user_input = mike.record_audio(lang=lan)
        user_input = user_input.lower()
        attempt = 0
        while correct == False:
            print("You said: " + user_input)
            if anmL[i] in user_input:
                print("Correct!")
                newP = newP + 1
                correct = True
            elif "quit" in user_input:
                main.save_progress()
                exit()
            else:
                if attempt < 3:
                    mike.mike("Let's try again, say ")
                    user_input = mike.record_audio(anmL[i], lan)
                else:
                    print("Let's move on")
                    correct = True
                attempt = attempt + 1

        i = i + 1
    return newP
示例#8
0
def greetings(lan):
    language = extras.get_language_long(lan)
    print("\n\nGreetings in " + language)
    print("---------------------------------------------------------")

    numEn = ["hi", "greetings", "good morning", "good afternoon", "good evening", "goodbye",
             "nice to meet you", "see you later", "see you soon", "how are you", "what's up"]

    numL = []
    for n in numEn:
        numOth = GoogleTranslator(
            source='en', target=lan).translate(text=n)
        numOth = numOth.lower()
        numL.append(numOth)

    newP = 0
    i = 0
    while i < 11:
        correct = False
        mike.mike(numEn[i] + " in " + language + " is ")
        mike.mike(numL[i], lan)

        mike.mike("Say " + numEn[i] + " in " + language)
        user_input = mike.record_audio(lang=lan)
        attempt = 0
        while correct == False:
            print("You said: " + user_input)
            if numL[i] in user_input:
                print("Correct!")
                newP = newP + 1
                correct = True
            elif "quit" in user_input:
                main.save_progress()
                exit()
            else:
                if attempt < 3:
                    mike.mike("Let's try again, say ")
                    user_input = mike.record_audio(numL[i], lan)
                else:
                    print("Let's move on")
                    correct = True
                attempt = attempt + 1
        i = i + 1
    return newP
示例#9
0
def sports(lan):
    language = extras.get_language_long(lan)
    print("\n\nSports in " + language)
    print("---------------------------------------------------------")

    numEn = ["basketball", "football", "running", "volleyball", "tennis", "golf",
             "rugby", "hockey", "badminton", "baseball", "archery"]

    numL = []
    for n in numEn:
        numOth = GoogleTranslator(
            source='en', target=lan).translate(text=n)
        numOth = numOth.lower()
        numL.append(numOth)

    newP = 0
    i = 0
    while i < 11:
        correct = False
        mike.mike(numEn[i] + " in " + language + " is ")
        mike.mike(numL[i], lan)

        mike.mike("Say " + numEn[i] + " in " + language)
        user_input = mike.record_audio(lang=lan)
        attempt = 0
        while correct == False:
            print("You said: " + user_input)
            if numL[i] in user_input:
                print("Correct!")
                newP = newP + 1
                correct = True
            elif "quit" in user_input:
                main.save_progress()
                exit()
            else:
                if attempt < 3:
                    mike.mike("Let's try again, say ")
                    user_input = mike.record_audio(numL[i], lan)
                else:
                    print("Let's move on")
                    correct = True
                attempt = attempt + 1
        i = i + 1
    return newP
示例#10
0
def food(lan):
    language = extras.get_language_long(lan)
    print("\n\nFood in " + language)
    print("---------------------------------------------------------")

    numEn = ["bread", "chicken", "beef", "meat", "fruit",
             "vegetable", "apple", "banana", "tomato", "carrot", "pizza"]

    numL = []
    for n in numEn:
        numOth = GoogleTranslator(
            source='en', target=lan).translate(text=n)
        numOth = numOth.lower()
        numL.append(numOth)

    newP = 0
    i = 8
    while i < 11:
        correct = False
        mike.mike(numEn[i] + " in " + language + " is ")
        mike.mike(numL[i], lan)

        mike.mike("Say " + numEn[i] + " in " + language)
        user_input = mike.record_audio(lang=lan)
        attempt = 0
        while correct == False:
            print("You said: " + user_input)
            if numL[i] in user_input:
                print("Correct!")
                newP = newP + 1
                correct = True
            elif "quit" in user_input:
                main.save_progress()
                exit()
            else:
                if attempt < 3:
                    mike.mike("Let's try again, say ")
                    user_input = mike.record_audio(numL[i], lan)
                else:
                    print("Let's move on")
                    correct = True
                attempt = attempt + 1
        i = i + 1
    return newP
示例#11
0
def buildings(lan):
    language = extras.get_language_long(lan)
    print("\n\nBuildings in " + language)
    print("---------------------------------------------------------")

    numEn = ["shop", "church", "gym", "library", "townhall",
             "house", "apartment", "school", "university", "factory", "police station"]

    numL = []
    for n in numEn:
        numOth = GoogleTranslator(
            source='en', target=lan).translate(text=n)
        numOth = numOth.lower()
        numL.append(numOth)

    newP = 0
    i = 0
    while i < 11:
        correct = False
        mike.mike(numEn[i] + " in " + language + " is ")
        mike.mike(numL[i], lan)

        mike.mike("Say " + numEn[i] + " in " + language)
        user_input = mike.record_audio(lang=lan)
        attempt = 0
        while correct == False:
            print("You said: " + user_input)
            if numL[i] in user_input:
                print("Correct!")
                newP = newP + 1
                correct = True
            elif "quit" in user_input:
                main.save_progress()
                exit()
            else:
                if attempt < 3:
                    mike.mike("Let's try again, say ")
                    user_input = mike.record_audio(numL[i], lan)
                else:
                    print("Let's move on")
                    correct = True
                attempt = attempt + 1
        i = i + 1
    return newP
def test_l2(lan):
    language = extras.get_language_long(lan)
    count = 0
    tPoints = 0
    # Five questions to test the most basic words
    while count < 4:
        phrase = random_test.simple_sentence()

        translated = GoogleTranslator(source='auto',
                                      target=lan).translate(text=phrase)
        if lan in tts_langs():
            mike.mike("Translate this phrase to English: ")
            mike.mike(translated, lan)
            answer = phrase
            userAnswer = mike.record_audio()
            print("You said: " + userAnswer + "\n The correct answer was: " +
                  phrase)
        else:
            # language not supported, alternative test, harder test
            answer = translated
            userAnswer = mike.record_audio(
                "What is " + phrase + " in " + language + "?", lan)
            print("You said: " + userAnswer + "\n The correct answer was: " +
                  translated)
            # extra 0.1 points per alternative question
            tPoints = tPoints + 0.1

        count = count + 1
        if len(userAnswer) > 0:
            if userAnswer in answer:
                print("+1")
                tPoints = tPoints + 1

    if tPoints > 3:
        tPoints = 3
    percent = (tPoints / 3) * 100
    print(percent)
    return percent