Im absolutely not sure which library is causing this or what is causing this but i really would appreciate some help. Although the error isn't messing up with the answers it pops up at the end of the program which im not sure why that is.
GITHUB : https://github.com/aaryanDhakal22/moccint
import pyttsx3
import speech_recognition as sr
import spacy
from study import study
from colored import fg, attr
r = sr.Recognizer()
mic = sr.Microphone()
nlp = spacy.load("en_core_web_lg")
for index, records in study.items():
question = records[0]
answer = records[1]
engine = pyttsx3.init()
engine.say(question)
engine.runAndWait()
engine.stop()
print("Listening now")
with mic as source:
r.adjust_for_ambient_noise(source)
audio = r.listen(source)
print("Done listening\n")
audio_traslated = r.recognize_google(audio)
print("Done Translating")
nlp_answers = nlp(answer)
nlp_user_answers = nlp(audio_traslated)
similarity = nlp_answers.similarity(nlp_user_answers)
if float(similarity) > 0.9:
print("%sPASSED%s" % (fg(2), attr(1)), similarity)
else:
print("%sFAILED%s" % (fg(1), attr(0)), similarity)
print("Q : " + question + "\n")
print("A : " + answer + "\n")
print("Your : " + audio_traslated + "\n")
Note :
- The error pops after the final line has been executed
- Running the code from vscode run and debug by pressing step over doesnt show the error
- The logic of the program works and the error doesnt seem to be influencing the answers
- The error occured towards the end so it probably isnt the setup or virtualenv fault , maybe the loop maybe something else not sure
I can't be sure, but it looks as though it's because something is trying to log during program exit, when some Python objects (including built-ins) become unavailable as the interpreter shuts down.