Function PoNanswer should return True or False, it is a loop which can be stoped only when you say Yes,... or No,... and when you say it, it should return. But very strangely it is not returning... How to fix it? thank you in advance)
def PoNanswer(voice_data):
for i in pANSWER_LIST:
if i in voice_data.split():
print('true')
return True
for i in nANSWER_LIST:
if i in voice_data.split():
print('false')
return False
voice_data = record_audio('I did not get it. Please repeat')
PoNanswer(voice_data)
class Command:
def __init__(self, raw_command):
self.raw_command = raw_command
self.key_word = False
self.action_word = False
self.processing()
def processing(self):
print(self.raw_command)
for i in self.raw_command.split():
if i in COMMANDS_LIST:
self.key_word = i
elif i in ACTION_WORD_LIST:
self.action_word = i
if self.key_word == COMMANDS_LIST[0]:
if self.action_word:
speak('ordering...')
main('-//-')
else:
if PoNanswer(record_audio(ADDITIONAL_QUESTIONS[0])):
self.raw_command = self.raw_command + "order"
print("mod")
self.processing()
else:
speak('Okay')
main('-//-')
self.processing()