Skip to content

Commit 521eaad

Browse files
style: format code with autopep8
Format code with autopep8 This commit fixes the style issues introduced in dd37743 according to the output from Autopep8. Details: None
1 parent dd37743 commit 521eaad

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

AI Language Learning Assistant/language_learning_assistant.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -588,62 +588,67 @@
588588
},
589589
]
590590

591+
591592
def vocabulary_quiz():
592593
print("AI Language Learning Assistant: Vocabulary Quiz")
593594
score = 0
594595
quiz_items = list(vocabulary.keys())
595596
random.shuffle(quiz_items)
596-
597+
597598
for word in quiz_items:
598599
user_answer = input(f"What does '{word}' mean? ")
599600
if user_answer.strip().lower() == vocabulary[word].lower():
600601
print("Correct!")
601602
score += 1
602603
else:
603604
print(f"Wrong. The correct answer is: {vocabulary[word]}")
604-
605+
605606
print(f"Quiz completed! Your score: {score}/{len(vocabulary)}")
606607

608+
607609
def grammar_exercise_quiz():
608610
print("AI Language Learning Assistant: Grammar Exercise")
609611
score = 0
610-
612+
611613
for item in grammar_exercise:
612614
user_answer = input(item['question'] + " ")
613615
if user_answer.strip().lower() == item['answer'].lower():
614616
print("Correct!")
615617
score += 1
616618
else:
617619
print(f"Wrong. The correct answer is: {item['answer']}")
618-
619-
print(f"Grammar exercise completed! Your score: {score}/{len(grammar_exercise)}")
620+
621+
print(
622+
f"Grammar exercise completed! Your score: {score}/{len(grammar_exercise)}")
623+
620624

621625
def interactive_conversation_practice():
622626
print("AI Language Learning Assistant: Interactive Conversation Practice")
623627
print("Type 'exit' to end the conversation.")
624-
628+
625629
while True:
626630
conversation = random.choice(conversations)
627631
user_input = input("ChatBot: " + conversation['question'] + " ")
628632
if user_input.lower() == 'exit':
629633
break
630634
print("ChatBot:", conversation['answer'])
631635

636+
632637
def detect_pronunciation_errors():
633638
print("AI Language Learning Assistant: Pronunciation Errors Detection")
634-
639+
635640
recognizer = sr.Recognizer()
636641
with sr.Microphone() as source:
637642
print("Speak a sentence for pronunciation evaluation:")
638643
recognizer.adjust_for_ambient_noise(source)
639644
audio = recognizer.listen(source)
640-
645+
641646
try:
642647
user_sentence = recognizer.recognize_google(audio)
643-
648+
644649
# Compare user_sentence with a pre-defined correct sentence to detect errors.
645650
# For simplicity, let's assume a fixed correct sentence.
646-
651+
647652
correct_sentence = "I love learning languages."
648653
if user_sentence.strip().lower() == correct_sentence.lower():
649654
print("Your pronunciation is great!")
@@ -654,6 +659,7 @@ def detect_pronunciation_errors():
654659
except sr.RequestError:
655660
print("Sorry, there was an error processing the audio. Please try again.")
656661

662+
657663
vocabulary_quiz()
658664
grammar_exercise_quiz()
659665
interactive_conversation_practice()

0 commit comments

Comments
 (0)