Improve speaking grading.
This commit is contained in:
10
app.py
10
app.py
@@ -8,7 +8,7 @@ from helper.file_helper import delete_files_older_than_one_day
|
||||
from helper.firebase_helper import download_firebase_file, upload_file_firebase, upload_file_firebase_get_url, \
|
||||
save_to_db
|
||||
from helper.heygen_api import create_video
|
||||
from helper.speech_to_text_helper import speech_to_text, text_to_speech, has_words
|
||||
from helper.speech_to_text_helper import speech_to_text, text_to_speech, has_words, has_10_words
|
||||
from helper.token_counter import count_tokens
|
||||
from helper.openai_interface import make_openai_call
|
||||
import os
|
||||
@@ -297,7 +297,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_words(answer):
|
||||
if has_10_words(answer):
|
||||
messages = get_grading_messages(QuestionType.SPEAKING_1, question, answer)
|
||||
token_count = reduce(lambda count, item: count + count_tokens(item)['n_tokens'],
|
||||
map(lambda x: x["content"], filter(lambda x: "content" in x, messages)), 0)
|
||||
@@ -306,7 +306,7 @@ def grade_speaking_task_1():
|
||||
return response
|
||||
else:
|
||||
return {
|
||||
"comment": "The audio recorded does not contain any english words.",
|
||||
"comment": "The audio recorded does not contain enough english words to be graded.",
|
||||
"overall": 0,
|
||||
"task_response": {
|
||||
"Fluency and Coherence": 0,
|
||||
@@ -391,7 +391,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_words(answer):
|
||||
if has_10_words(answer):
|
||||
messages = get_grading_messages(QuestionType.SPEAKING_2, question, answer)
|
||||
token_count = reduce(lambda count, item: count + count_tokens(item)['n_tokens'],
|
||||
map(lambda x: x["content"], filter(lambda x: "content" in x, messages)), 0)
|
||||
@@ -400,7 +400,7 @@ def grade_speaking_task_2():
|
||||
return response
|
||||
else:
|
||||
return {
|
||||
"comment": "The audio recorded does not contain any english words.",
|
||||
"comment": "The audio recorded does not contain enough english words to be graded.",
|
||||
"overall": 0,
|
||||
"task_response": {
|
||||
"Fluency and Coherence": 0,
|
||||
|
||||
Reference in New Issue
Block a user