From cc3371c5978f37fe550aa9fe4fa6a23e2dfc99f1 Mon Sep 17 00:00:00 2001 From: Pedro Fonseca Date: Sun, 24 Mar 2024 10:37:02 +0000 Subject: [PATCH] Updated has_10_words to has_50_words --- app.py | 6 +++--- helper/speech_to_text_helper.py | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app.py b/app.py index c49a20f..09a1d43 100644 --- a/app.py +++ b/app.py @@ -368,7 +368,7 @@ def grade_speaking_task_1(): download_firebase_file(FIREBASE_BUCKET, answer_firebase_path, sound_file_name) answer = speech_to_text(sound_file_name) - if has_10_words(answer): + if has_50_words(answer): message = ("Evaluate the given Speaking Part 1 response based on the IELTS grading system, ensuring a " "strict assessment that penalizes errors. Deduct points for deviations from the task, and " "assign a score of 0 if the response fails to address the question. Additionally, provide " @@ -447,7 +447,7 @@ def grade_speaking_task_2(): download_firebase_file(FIREBASE_BUCKET, answer_firebase_path, sound_file_name) answer = speech_to_text(sound_file_name) - if has_10_words(answer): + if has_50_words(answer): message = ("Evaluate the given Speaking Part 2 response based on the IELTS grading system, ensuring a " "strict assessment that penalizes errors. Deduct points for deviations from the task, and " "assign a score of 0 if the response fails to address the question. Additionally, provide " @@ -559,7 +559,7 @@ def grade_speaking_task_3(): text_answers.append(answer_text) item["answer"] = answer_text os.remove(sound_file_name) - if not has_10_words(answer_text): + if not has_50_words(answer_text): return { "comment": "The audio recorded does not contain enough english words to be graded.", "overall": 0, diff --git a/helper/speech_to_text_helper.py b/helper/speech_to_text_helper.py index a08403f..5684165 100644 --- a/helper/speech_to_text_helper.py +++ b/helper/speech_to_text_helper.py @@ -94,11 +94,11 @@ def has_words(text: str): words_in_input = text.split() return any(word.lower() in english_words for word in words_in_input) -def has_10_words(text: str): +def has_50_words(text: str): english_words = set(words.words()) words_in_input = text.split() english_word_count = sum(1 for word in words_in_input if word.lower() in english_words) - return english_word_count >= 10 + return english_word_count >= 50 def divide_text(text, max_length=3000): if len(text) <= max_length: