Add verification for words in speaking grading.
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
import whisper
|
||||
import os
|
||||
import gtts
|
||||
from playsound import playsound
|
||||
import nltk
|
||||
nltk.download('words')
|
||||
from nltk.corpus import words
|
||||
|
||||
def speech_to_text(file_path):
|
||||
if os.path.exists(file_path):
|
||||
@@ -14,4 +16,9 @@ def speech_to_text(file_path):
|
||||
|
||||
def text_to_speech(text: str, file_name: str):
|
||||
tts = gtts.gTTS(text)
|
||||
tts.save(file_name)
|
||||
tts.save(file_name)
|
||||
|
||||
def has_words(text: str):
|
||||
english_words = set(words.words())
|
||||
words_in_input = text.split()
|
||||
return any(word.lower() in english_words for word in words_in_input)
|
||||
Reference in New Issue
Block a user